wpf

How to bind Checked event for radio button in WPF?

I am using the following markup in WPF: <StackPanel.Triggers> <EventTrigger RoutedEvent="RadioButton.Checked" SourceName="xmlRadioButton"> <EventTrigger.Actions> <BeginStoryboard Storyboard="{StaticResource ShowXmlPanel}"/> </EventTrigger.Actions> </EventTrigger> <Event...

WPF ItemsViewSource Sorting

Greetings, I have a problem with sorting ItemsViewSource in WPF. The problem is as follows: My application has a listbox with items, there is a possibility to add new items to this listbox. I have ItemsViewSource which is of type CollectionViewSource and bouned to ObservableCollection as follows: _ItemsViewSource.Source = Children; W...

WPF resource merged to Application.Resources but not resolved at runtime

I have a brush that is part of a ResourceDictionary that is merged to Application.Resources. But for some reason it's not resolved at runtime when a style is being applied to one of the controls. However, if I call Application.Current.FindResource("BrushName") from the Immediate Window at the time when exception is thrown, the resource ...

WPF generic colors based on SystemColors

I need to have some generic colors in my application, which are based on the system colors, which change based on the active theme. So I believe I need some IValueConverters that each return a brush when given a system color brush. But where do I put the logic? As I see it I might have 2 options. Option 1) place SolidColorBrush(es) in ...

What is a good way to factor out and simplify a complicated WPF custom control?

I am looking for a good way to simplify and organise a complicated WPF custom control. My first thought is to factor it out into two simpler controls. For the sake of explanation I'll call these SimpleControl and AdvancedControl. SimpleControl contains all the core functionality and is extremely reusable. AdvancedControl depends u...

Change type of control by type

Hi, I'm having following problem. I should convert a control to a certain type, this can be multiple types (for example a custom button or a custom label, ....) Here's an example of what i would like to do: private void ConvertToTypeAndUseCustomProperty(Control c) { Type type = c.getType(); ((type) c).CustomPropertieOfControl...

adding child nodes to a treeview control in wpf,c#

Hi , i have implemented a treeview control on a buttonclick event like this: namespace TaxonomyTreeview { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { ObservableCollection<TaxonomyData> _TaxonomyCollection = new ObservableCollection<TaxonomyData>...

binding data to combo box column in gridview in wpf

How to bind data to a combox column in a grid view in listview's view. I have a Gridview in listview's view. Inside grid I have a grid column which contains a row of combo box. How to bind data to this combo box using DataTable or DataSet? Please help :-) ...

Binding the position and size of a UserControl inside a Canvas in WPF

Hi. We need to dynamically create (i.e. during runtime, via code-behind) UserControls and position them on a Canvas. We want to bind the position (Canvas.Left and Canvas.Top) and width of those sizable (!) and draggable (!) UserControls to a ObservableCollection<>. That measn when the user drags or resizes the control, the datasource get...

Disable Drag-drop from TextBox

I have a WPF textBox that is declared as ReadOnly <TextBox IsReadOnly="True" IsTabStop="False" Width="200" /> So, User can not write anything into the TextBox or delete the content but it still allows user to drag the text from this textbox and drop it in any other textbox that caused the text removed from the first textbox(the read-o...

In my listview the PropertyChanged event never triggers the list to be redrawn

Hi everybody. First of all, I've to admin that I'm absolutely new to WPF! I think I've a problem with WPF Bindings or "PropertyChanged" notifications... I have this XAML with a TextBlock and a listView <StackPanel Orientation="Horizontal"> <TextBlock Margin="2" Name="UpdatesOperationResultcaption" Text="Operatio...

How to get a majority color in an image?

I want to retrieve the majority color in a background image in .NET. Is it possible? ...

How to force a TextChanged event on a WPF TextBox and mantain the focus?

I am creating a numeric TextBox in WPF, with two buttons to increase and decrease the value. I have create two RoutedCommand to manage the behiavor and they are working well. There is only one problem that I would like to solve. I would like that the control notifies all object binded to its TextProperty when an increase or decrease com...

Re-using Buttons in WPF

I have a bunch of different objects that are commonly edited in the same TabControl using different DataTemplates, but I want each DataTemplate to have a common look and feel with Ok and Cancel buttons at the bottom right of each tab that will close the tab or save the content and then close the currently selected tab. What's the best w...

WPF Binding in Style

Hi, I'm trying to set together a simple textbox with some watermark text in the background. My code is based on the example from Philip Patrick's blog. I'm trying to tweak it so that the text displayed in the background is retrieved from the ToolTip property on the TextBox. Currently this works: <TextBox ToolTip="Type a name here...">...

Adding programatically a command to a listbox in WPF

In my WPF application there is a listbox with items. The listbox is populated via a xmldataprovider from XAML and then binding it to Itemssource property of the listbox. Well, from XAML, I bind a comand to the listbox by doing: <ListBox.CommandBindings> <CommandBinding ...

Storyboard apply to all labels

Hi everyone ! I whant to apply a little storyboard to a collection of labels in my window. My storyboard is like that : <Storyboard x:Key="Storyboard1" AutoReverse="True" RepeatBehavior="Forever"> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label" Storyboard.TargetProperty="(Label.Foreground).(Soli...

How to make a WPF window be on top of all other windows of my app (not system wide)?

I want my window to be on top of all other windows in my application only. If I set the TopMost property of a window, it becomes on top of all windows of all applications and I don't want that. ...

Force ListViewItem Background colour to change when bound item it is bound to changes.

My ItemContainerStyle works perfectly when a ListViewItem is added: <Style x:Key="ItemContStyle" TargetType="{x:Type ListViewItem}"> <Style.Resources> <SolidColorBrush x:Key="lossBrush" Color="Red" /> <SolidColorBrush x:Key="newPartNo" ...

Do not show partial items in a WPF listbox

I've tried Google and I've tried Bing to no avail. Does anyone here have an idea on how to prevent partial items from appearing in a listbox in WPF? In case that does not make sense here is an example: Listbox is 200 pixels tall - each item is 35 pixels tall. That means I can show 5.7 items. 7/10 of an item is undesirable. I'd like...