There is a DataGrid in which there is a DataGridComboBoxColumn column, the values ​​for this field are filled with a search when entering some characters, the problem is that after selecting an item in ComboBox and switching the focus to another cell, the selected item is not visible. In which direction to dig, tell me ?:

<DataGrid.Columns> <DataGridComboBoxColumn Width="300" Header="Полное наименование" IsReadOnly="False" SelectedValuePath="Key"> <DataGridComboBoxColumn.EditingElementStyle> <Style TargetType="ComboBox"> <Setter Property="IsEditable" Value="True" /> <Setter Property="DisplayMemberPath" Value="Value" /> <Setter Property="ItemsSource" Value="{Binding ProductModelCombo.ListProductCombo, UpdateSourceTrigger=PropertyChanged}" /> <Setter Property="Text" Value="{Binding ComboTextProduct, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" /> <Setter Property="SelectedValue" Value="{Binding SelectedComboProduct, UpdateSourceTrigger=PropertyChanged}" /> <Style.Triggers> <EventTrigger RoutedEvent="TextBoxBase.TextChanged"> <BeginStoryboard> <Storyboard> <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsDropDownOpen"> <DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="True" /> </BooleanAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </Style.Triggers> </Style> </DataGridComboBoxColumn.EditingElementStyle> </DataGridComboBoxColumn> <DataGridTextColumn MinWidth="50" Binding="{Binding Path=ProductModelObject.Quantity}" Header="Кол-во" IsReadOnly="False" /> <DataGridTextColumn MinWidth="50" Binding="{Binding Path=ProductModelObject.ProductSale.RetailPrice}" Header="Розничная цена" IsReadOnly="True" /> <DataGridTextColumn MinWidth="50" Binding="{Binding Path=ProductModelObject.ProductSale.Barcode}" Header="Штрих-код" IsReadOnly="True" /> </DataGrid.Columns> </DataGrid> 

ProductModelCombo.ListProductCombo - has type Dictionary<int, string>

  • Does selectedComboProduct work? Does anyone rub it? null not thrust? - Arheus 1:53 pm
  • SelectedComboProduct works, everything is fine with it. All data is pulled up and displayed, but the problem is with the combobox column. Of course, you can replace it with datagridtemplatecolumn and insert a combo there, but I would like to make it more aesthetic - Boris Vladimirovich
  • In my opinion, datagridtemplatecolumn is a more aesthetic option :). Perhaps it's in <DataGridComboBoxColumn.EditingElementStyle>. Those. Only in Edit mode, judging by the name. Because and when there is a switch in ShowStyle or something like that, the binding given by the style also flies. - Arheus
  • DataGridComboBoxColumn.DefaultElementStyle need to be added. With appropriate binding. - Arheus
  • Thank you very much. Judging by the logic you are right. I will try to implement it a bit later - Boris Vladimirovich

0