November 2012 Entries
WPF DataGrid using a DataGridTemplateColumn rather than a DataGridComboBoxColumn to show selected value at load

My problem was that using a DataGridComboBoxColumn I couldn’t get it to show the selected value when the DataGrid loaded.  Instead, the user would have to click in the cells and like magic, the current selected values would appear and it looked the way I wanted it to on load.

Here is what I had

<DataGridComboBoxColumn MinWidth="150" x:Name="crewColumn" Header="Crew" 
     ItemsSource="{Binding JobEdit.Crews, Source={StaticResource Locator}}"  
     SelectedItemBinding="{Binding JobEdit.SelectedCrew, Mode=TwoWay, Source={StaticResource Locator}}" 


Here is what I changed it too.  This works great.  It displays the selected item when the DataGrid loads and shows the combo box when the user goes into edit mode.


                           <DataGridTemplateColumn Header="Crew" MinWidth="150">
                                                <TextBlock Text="{Binding Crew.Name}"></TextBlock>
                                                <ComboBox ItemsSource="{Binding JobEdit.Crews, Source={StaticResource Locator}}"  
                                                   DisplayMemberPath="Name" SelectedItem="{Binding JobEdit.SelectedCrew, Mode=TwoWay, 
                                                   Source={StaticResource Locator}}"></ComboBox>
Expression Blend + Sketchflow Preview for Microsoft Visual Studio 2012

Expression Blend has released a preview version of Blend that addresses some of the missing features of the version of Expression Blend that ships with VS 2012.   Here is a download to the preview version that has a lot of the features that were missing in the shipped version.  My suggestion is that anyone that works with Xaml and VS 2012 download this version of Blend