I am using a combobox inside a template field, but when an item is selected, entity linked is not reflected about that. In the below snippet - SelectedFieldName is not set when ever we change anything in combobox
<dataPresenter:TemplateField Name="FieldName" AlternateBinding="{Binding SelectedFieldName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AlternateBindingRetentionMode="Retain" Label="FieldName" > <dataPresenter:TemplateField.DisplayTemplate> <DataTemplate> <!--SelectedItem="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type dataPresenter:CellValuePresenter}}, Path=Record.DataItem.SelectedFieldName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"--> <ComboBox SelectedItem = "{editors:TemplateEditorValueBinding Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource FieldValues}}" </DataTemplate> </dataPresenter:TemplateField.DisplayTemplate> <dataPresenter:TemplateField.EditTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding Source={StaticResource FieldValues}}" SelectedItem ="{editors:TemplateEditorValueBinding Mode=TwoWay}" /> </DataTemplate> </dataPresenter:TemplateField.EditTemplate> </dataPresenter:TemplateField>
I got it working myself. Changed
<dataPresenter:TemplateField Name="FieldName" BindingType="Unbound" Label="FieldName" > <dataPresenter:TemplateField.DisplayTemplate> <DataTemplate> <ComboBox SelectedItem="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type dataPresenter:CellValuePresenter}}, Path=Record.DataItem.SelectedFieldName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Source={StaticResource FieldValues}}" /> </DataTemplate> </dataPresenter:TemplateField.DisplayTemplate> <dataPresenter:TemplateField.EditTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding Source={StaticResource FieldValues}}" SelectedItem ="{editors:TemplateEditorValueBinding Mode=TwoWay}" /> </DataTemplate> </dataPresenter:TemplateField.EditTemplate> </dataPresenter:TemplateField>
Hello Tarun,
Thank you for your feedback.
I am very glad that you have manage to resolve the issue.
If you require any further assistance, please do not hesitate to ask.
Sincerely,
Radko
Senior Software Developer