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

How to loop over the rows of a WPF toolkit Datagrid

this will return a ‘row’ in your datagrid public IEnumerable<Microsoft.Windows.Controls.DataGridRow> GetDataGridRows(Microsoft.Windows.Controls.DataGrid grid) { var itemsSource = grid.ItemsSource as IEnumerable; if (null == itemsSource) yield return null; foreach (var item in itemsSource) { var row = grid.ItemContainerGenerator.ContainerFromItem(item) as Microsoft.Windows.Controls.DataGridRow; if (null != row) yield return row; } } in wpf datagrid, rows are ItemSource.items… no Rows … 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>