Category Archives: WPF

Disable Visual Studio XAML design mode

In VS2015 goto:

Tools > Options > Xaml Designer

Choose “Source View” for “Default Document view”

or you can disable it completely by unchecking “Enable XAML Designer”

Set App.xaml StartupUri to xaml from another project

<Application x:Class="BH.Chart.Wpf.App"


WPF ComboBoxColumn

Difference between SelectedItemBinding and SelectedValueBinding is:

  1. SelectedItemBinding assumes the item is a custom object whereas
  2. SelectedValueBinding assumes the binding is to a string or some other primitive types.

WPF Databind to read-only DataGrid.SelectedItems property

Thanks a million to the reference below:

I have spent one day looking for a MVVM solution to bind to DataGrid.SelectedItems property. WPF does not allow this because DataGrid.SelectedItems is read-only. However, I need to get hold of all selected items when performing “delete” action, or just to decide if a right-click menu item should appear or not, and I CAN’T!!!

After a day’s Googling and trying out millions of not-straightforward-and-ultimately-not-working ways, I have found the article above, which consists of 3 simple classes that just work! I would really like to share this with others who are having this trouble.

WPF DataGrid tricks

  • Edit in upper case for a text column:
    <DataGridTextColumn Header="Fund" Binding="{Binding Fund}">
             <Style TargetType="TextBox">
                 <Setter Property="CharacterCasing" Value="Upper"/>
  • String.Empty in an array
     <x:Static Member="system:String.Empty" />
  • DataGridComboBoxColumn bindings
     <DataGridComboBoxColumn Header="FundShare"
     SelectedItemBinding="{Binding FundShare}"
     ClipboardContentBinding="{Binding FundShare.FundShareName}"
     ItemsSource="{Binding Source={x:Static viewmodel:IFSFundMappingViewModel.FundShares}}">