wpf

WPF TextBox DataBind on EnterKey press

The default DataBinding on TextBox is TwoWay and it commits the text to the Property only when TextBox lost its focus. Is there any easy XAML way exists to make the DataBinding Happens when I press Enter Key on the TextBox?. I know it is pretty easy to do in the code behind, but imagine if this textBox is inside some complex DataTemplate...

XAML For Reflection Effect

I'm a XAML/WPF newbie, and I thought I'd write an alarm clock application to get into it. I want to get past the basic textboxes, dropdowns etc, which are fairly simple once you get the hang of the layout model, but I'd like to get into the graphics side of things. I'd like to display alarm clock digits on a black backdrop, but importa...

Setting IsCheckable seems to prevent submenus from showing up

I'm trying to bind IsChecked to the Selected DependancyProperty on the object I'm displaying, this code appears to work, but submenus don't show up if I use it. Is this the right way to go about it, and how do I fix the problem? <MenuItem Header="Window" Name="windowMenu" ItemsSource="{Binding}"> <MenuItem.ItemContainerStyle> ...

How can I make a ElementHost transparent so that the form behind it is visible and clickable?

I tried to derive a class form ElementHost and overiding the CreateParams method: protected override CreateParams CreateParams { get { const int WS_EX_TRANSPARENT = 0x20; CreateParams cp = base.CreateParams; cp.ExStyle = cp.ExStyle | WS_EX_TRANSPARENT; return cp; ...

A lightweight templateable WPF shape

I'm using ellipses and other shapes as onscreen markers, I would like others to be able to change these visuals using templates. However, as shape doesn't support templating I'm forced to create a basic UserControl, which defaults to show an ellipse, and then use that instead of the basic shape. Has anyone got a neater solution? I'm a l...

Expose multiple command in WPF user control

A better explanation, I hope: I have a toolbar with 3 buttons on it, all three bound to a Command (including a CommandParameter) this toolbar is used on several screens the xaml of the toolbar is exactly the same over all those screens I want to remove the toolbar instance and replace it with a user control that provides 3 commands, ...

How to get MessageBox.Show() to pop up in the middle of my WPF application?

I have a 700w x 300h WPF applciation and can drag it anywhere on my large screen. When my application executes: MessageBox.Show("Sorry, this function is not yet implemented."); the mesage box appears in the middle of my screen, which may or may not even be near the application itself. How can I get my MessageBox to appear in the mid...

Styling a WPF layout grid background (of each cell, row, column)

I would like to know if there is any way to style a WPF layout grid's cells, rows and columns. I've been trying to find any information and the few mentions I've found have not been that informative. I would like to style the grid to look like the one in the linked screenshot. If the actual control does not support it, can I inherit it...

How to dynamically embed a XAML/Codebehind pair as a child of a StackPanel?

I have a StackPanel called "MainContent". I can dynamically fill it with UIElements like this: TextBlock textBlock = new TextBlock(); textBlock.Text = String.Format("This is text"); textBlock.Background = new SolidColorBrush(Colors.Beige); MainContent.Children.Add(textBlock); Button button = new Button(); button.Content = "This is a b...

Extending WPF Button to store data in a new property

I want to extend a WPF button to store some extra data, in a similar way to the current "Tag" property. Are attached properties the way forward? The data I want to store will be a URL Link string, for example I would like to be able to do something like: <Button Tag="BBC World News" URLLink="http://www.bbc.co.uk"/&gt; Can anyone hel...

Inner glow effect in WPF

Short question :) Does anyone have a method for creating a Inner glow effect in WPF? ...

Creating a common window look in WPF

How would I create a common window look in WPF? I'm not talking about just styling the window, I'm mean having a window that has a border, grid, and some other things in it. Thanks. ...

WPF Listview bound with Hashtable

I already bind a listview (grid) with hashtable, so how can I get items from there? Before using hashtable I just did ListViewA.SelectedItems; and I was getting the source. Ir fails when I use two foreach loops: dlstTemplates is my ListView in WPF foreach (var group in dlstTemplates.SelectedItems) { foreach (var Template in group) ...

Strange behavior when using lambda expression on WPF buttons click event.

My problem is hard to explain, so I created an example to show here. When the WPF window in the example below is shown, three buttons are displayed, each one with a different text. When anyone of these buttons is clicked, I assume its text should be displayed in the message, but instead, all of them display the same message, as if all ...

Is there a "All Children loaded" event in WPF

I am listening for the loaded event of a Page. That event fires first and then all the children fire their load event. I need an event that fires when ALL the children have loaded. Does that exist? ...

WPF RichTextBox to create editor with line numbers

I'm creating a text editor for a domain specific language. I'm using the WPF RichTextBox as the basic control. I don't know how to gracefully include line numbering. Does anyone know of any examples? ...

WPF Window Drag/Move Boundary

Hi everyone, just curious if you know of any way to setup a drag boundary for a window? It would be nice to have these properties: Me.MinLeft = 10 Me.MinTop = 10 Me.MaxLeft = 150 Me.MaxTop = 150 Those are made up properties, btw, which would be nice to have. I know I could probably setup a timer to fire ever 10th of a second and che...

What is the correct way to dispose of a WPF window?

I have a WPF window which I am creating from another window, show()ing, then letting it close() itself. When the window closes, I expect it to die, call its constructor, and delete all its child elements (such as timers..). What is the correct way of invoking this action? ...

How to add additional attributes to standard XAML elements?

This button click method launches a Window called "(assemblyname).Reports" when a button with Content "Reports" is clicked: private void Button_Click(object sender, RoutedEventArgs e) { Button button = (Button)e.OriginalSource; Type type = this.GetType(); Assembly assembly = type.Assembly; Window window = (Window)assembl...

WPF XAML: how to get StackPanel's children to fill maximum space downward?

I simply want flowing text on the left, and a help box on the right. The help box should extend all the way to the bottom. If you take out the outer StackPanel below it works great. But for reasons of layout (I'm inserting UserControls dynamically) I need to have the wrapping StackPanel. How do I get the GroupBox to extend down to th...