wpf

Receiving EditingCommands on derived InlineUIContainer

I have a class that derives from InlineUIContainer. I want to take an action when an editing command (like ToggleBold) is performed on a FlowDocument selection that includes an instance of this class. I've tried registering for this command but it isn't raised. I've tried overriding OnPropertyChanded, but it is only called on explicit...

Binding a save command WPF

I have a window with 3 textboxes in a grid -this is my view- and I have Save button to add a new user to my user list with the datas from the textboxes. I want to use a relay command to do this on my viewmodel class but I am quite confused with how to make the bindings. I hope it's clear enough. Any ideas, or examples will be helpful. t...

WPF ListBoxItem how to wrap Text in it?

WPF ListBoxItem how to wrap text in it? My Item container style looks like this: <Style x:Key="GroupListBoxItemStyle" TargetType="ListBoxItem"> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Sette...

WPF - DataGrid Column with Width="*", but MinWidth to Fit Contents

Hi, What would be the best/right way to have a set of DataGrid columns have proportional width (Width="*"), but to have their MINIMUM width be at least the width of their content? At the moment, if I use Width="*", then the columns stay exactly proportional, but content gets cropped if the columns get too thin. If I use Width="Auto", th...

How do I simulate Text input to a WPF TextBox?

I want to simulate user input to a WPF TextBox. I want to input a character such that the OnPreviewTextInput event is triggered. I tried setting the Text through the Text property, but this didn't trigger the event: public void SomeFunction() { var textBox = new TextBox(); textBox.Text = "A"; } Can I trig...

wpf: Access parent DataContext from DataTemplate

I have a ListBox which binds to a child collection on a ViewModel. The listbox items are styled in a datatemplate based on a property on the parent ViewModel: <Style x:Key="curveSpeedNonConstantParameterCell"> <Style.Triggers> <DataTrigger Binding="{Binding Path=DataContext.CurveSpeedMustBeSpecified, ...

Swap input character to WPF TextBox before it is added to the Text

I have a TextBox which I'm using to handle numbers. I therefore only accept [0-9.,]. However, "." is the only valid decimal separator. I therefore only want this in my text, but I want to accept "," too, and swap it with a "." such that the displayed character is a valid one. So - how do I swap an input character? I'm assuming I can fe...

Visual Studio build problem with "ReflectionOnlyAssemblyResolve event"

I have a visual studio 2010 project that is trageted to .Net Framework 3.5. The project build fine from the Visual Studio but when I try to compile it from command line or from TeamCity I get the following build error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFX.targets(269,9): error MC1000: Unknown build error, 'Ca...

What are routed events and how it's different from normal events.

I will appreciate if some body can explain with a simple example. ...

How to bind toolbar buttons on MVVM Pattern?

Hi, How can I bind a collection of Commands in viewmodel to a toolbar in related view? ...

How to implement WPF Dynamic UI

I'm developing a WPF applicaition to try and get a better understanding of what it's about and what it can do. I've got a situation though which I'm not sure how best to implement, where basically my UI needs to change depending on user selection. Essentially I wish to build up a set of 'ConditionRows', where the user specifies a 'Field...

WPF TabControl collapsed tab headers are not completely hidden

I am using a TabControl to programmatically show or hide groups of form controls. I have implemented the technique described here and it approximately works as expected, except that there is a band approximately 1 or 2 pixels high in the location where the tab headers are normally displayed. I have verified this by using Snoop to naviga...

How to filter on a constantly updated collection displayed in grid?

Hi, Let's say I have a WPF application that shows "questions". Questions can have different statuses, such as "open", and "answered". The questions are stored in an ObservableCollection and displayed on a DataGrid. I want to have a toggle button at the top that switches between "open" and "answered" questions. When a user clicks the "...

Binding to an ancestor in WPF

I have a window in one assembly that has a TextBlock control that I want to bind to the value of a Property of a class that is the property of the DataContext of that windows parent. The class that is serving as the DataContext is only defined within the second assembly. My question is what type do I need to specify as the Type in my b...

Make ListView ignore rightclick totally

Hello, I'am just coding some global gesture handlers for a wpf application. For example I am supposed to use right click as a trigger to proceed UI. <Window.InputBindings> <MouseBinding MouseAction="RightClick" Command="NavigationCommands.NextPage"/> </Window.InputBindings> But now the problem appears that <ListBox/> consume...

What is simplest way to repeat a video in a MediaElement

I have a MediaElement where the source is bound to some data <MediaElement Source='{Binding Something}' /> What is the simplest way to have the video repeat? Ideally, MediaElement would have a repeat behavior property. <MediaElement RepeatBehavior='Forever' ... /> But I can't find such a property. ...

WPF, display attribute value in TreeView instead of node name

If I have the following data template for a TreeView, what do I need to change so that each TreeViewItem shows the value of the name attribute on each XML node, instead of the node name? <HierarchicalDataTemplate x:Key="NodeTemplate"> <TextBlock x:Name="tb"/> <HierarchicalDataTemplate.ItemsSource> <Binding XPath="child::...

IActiveAware Interface in Prism

Can someone shed some light on active aware interface is in Prism, how it helps delegate command. ...

WPF: Reset Colors to use template colors

Hi, I currently have a listboxitemcontainer, which if selected turns the background blue. However later I programatically set : Border.Background = new solidcolorbrush(colors.white); How do I reset the the border background now to use the template colors again? Now when I select the box again, it doesn't turn to the selection color an...

How can I set the keyboard focus to the content of a ContentPresenter when it changes?

I have a ContentControl in my view which is databound to the CurrentItem property of my viewmodel. The objects that are exposed via CurrentItem each has its own DataTemplate. When the CurrentItem property changes, the appropriate DataTemplate for that item is displayed, as it should be. However, I cannot find out a way to set the keyb...