示されているように、 DataGridで定義されたComboBoxがあります。ComboBoxのは、プロパティを含むカスタム クラスのリストです。はプロパティで、はプロパティです。はDataGridのプロパティにバインドされています。( DataGridの はビューであることに注意してください。) ComboBoxは適切に設定され、 ComboBox選択のプロパティへのバインドも同様に機能します。すべて問題なく、新しいデータに適しています。問題は、の既存のデータにあります。ItemsSource
CodePickList
Name
ID
DisplayMemberPath
Name
SelectedValuePath
ID
SelectedValue
GLCode
ItemsSource
ItemsSource
GLCode
ItemsSource
データグリッド。ComboBox のテキストブロックは単に空白です。ComboBox ItemsSource が読み込まれると、ComboBoxはDataGridのプロパティとComboBoxGLCode
のプロパティを一致させることができないようです。これらのプロパティは同じタイプです。WinForms はこのシナリオを処理しますが、WPF で動作させることはできません。 ItemsSource
ID
ItemsSource
<DataGrid ItemsSource="{Binding EntityDetailsView.View}">
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{BindingPath=DataContext.CodePickList, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
DisplayMemberPath="Name" SelectedValuePath="ID" SelectedValue="{Binding GLCode, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
IsEditable="False" IsReadOnly="False"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>