Windows 7 theme for WPF?

WPF comes with the standard Windows themes on all Windows versions. For example, you can have the Aero theme (which Vista and Windows 7 use) on Windows XP with the following steps: Add PresentationFramework.Aero to your application’s references list as a requires Edit your App.xaml from this <Application.Resources> <!– Your stuff here –> </Application.Resources> to … Read more

Bind datagrid column visibility MVVM

DataGridColumns are not part of visual tree so they are not connected to the data context of the DataGrid. For them to connect together use proxy element approach like this… Add a proxy FrameworkElement in your ancestor panel’s Resources. Host it into an invisible ContentControl bound to its Content. Use this ProxyElement as StaticResource for … Read more

Changing the string format of the WPF DatePicker

I have solved this problem with a help of this code. Hope it will help you all as well. <Style TargetType=”{x:Type DatePickerTextBox}”> <Setter Property=”Control.Template”> <Setter.Value> <ControlTemplate> <TextBox x:Name=”PART_TextBox” Text=”{Binding Path=SelectedDate, StringFormat=”dd MMM yyyy”, RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}” /> </ControlTemplate> </Setter.Value> </Setter> </Style>

WPF StringFormat on Label Content

The reason this doesn’t work is that the Label.Content property is of type Object, and Binding.StringFormat is only used when binding to a property of type String. What is happening is: The Binding is boxing your MaxLevelOfInvestment value and storing it the Label.Content property as a boxed decimal value. The Label control has a template … Read more

How can I apply a custom sort rule to a WPF DataGrid?

this is how i do it : I do derive from the grid to keep all of this inside the class, so i attach to event handlers internally attach to the sorting event dataGrid.Sorting += new DataGridSortingEventHandler(SortHandler); implement the method (i do this in a derived class) void SortHandler(object sender, DataGridSortingEventArgs e) { DataGridColumn column … Read more