So we have a WPF DataGrid with some ComboBoxes in some of the cells where there is a foreign relation, but this means we have hundreds of ComboBoxes loaded at a time which takes too long. What we would like to do is load a label until it is clicked on at which point a ComboBox is loaded, we can easily do this with a TextBox.
The problem is, our comboboxes work and allow the user to change the foreign key value in the column by selecting from a number of display values (e.g. {Car, Dog, Cat}). But before the user clicks on the label, the label displays the foreign key value itself (e.g. {1, 2, 3}).
Any ideas on what we could do? Any help most appreciated!
<DataGridTemplateColumn Header="Column Name" SortMemberPath="Column Name">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding Path=DataViewBehindColumnName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox
DataContext="{DynamicResource ResourceKey=ViewModel}"
ItemsSource="{Binding Path=ReferenceTableName,
Converter={StaticResource dataViewToListConverter}}"
DisplayMemberPath="ReferenceTableDisplayNamesColumn"
SelectedValuePath="ReferenceTablePrimaryKeyColumn"
SelectedValue="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}},
Path=Item[DataViewBehindColumnName]}"
/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
Kind regards, Fugu