Hi Everyone,
I need to implement autosuggest feature in a DataGridTextColumn. How can I achieve this?
I am looking for solution with as little project dependency as possible
What I have tried:
I have tried a couple approaches but everything seems to have its own problem. This is my closest attempt to implement the feature, however, this approach does not allow me to input text or any kind into the textbox within the DataGridTemplateColumn
<pre>
<DataGridTemplateColumn Header="Product Number" Width="120">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock x:Name="ProductNumberBox" Text="{Binding ProductNumber, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
<Popup Width="{Binding Path=ActualWidth, ElementName=ProductNumberBox}" StaysOpen="False" PlacementTarget="{Binding ElementName=ProductNumberBox}" Placement="Bottom" IsOpen="{Binding DataContext.GridPopupIsOpen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
<ListBox ItemsSource="{Binding DataContext.Parts, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" SelectedItem="{Binding DataContext.SelectedSuggestedPartInGrid, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ProductNumber}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Popup>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>