I have a combobox inside of my WPF DataGrid. It is created like this:
<DataGridTemplateColumn Header="Account">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Account, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{DynamicResource Accounts}" SelectedValue="{Binding Path=Account, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Height="23" IsTextSearchEnabled="True"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
The DataContext for this datagrid is an ObservableCollection. The Transaction class has a Property called “Account” Below is how I create this property:
public string Account
{
get { return account; }
set { account = value; NotifyPropertyChanged("Account"); }
}
What am I doing wrong here? When I choose an item from the ComboBox, nothing is displayed after I click outside of the box. When I set a break point in the Set method of the Account Property, the value is null.
Fixed my issue. I had to set the
Textproperty binding.