Reputation: 442
I have a datagrid in my application (sales invoice form) with five columns. One column needs to be autocompletebox control. I'd like to implement the whole thing using the MVVM pattern.
How can i solve the issue..
Upvotes: 1
Views: 969
Reputation: 216
I have added the AutoCompleteBox column to the datagrid.
Have the DataTemplate in resources.
<DataTemplate x:Key="AutoCompleteTemplate">
<tool:AutoCompleteBox ItemsSource="{Binding Source}"/>
</DataTemplate>
<DataGrid>
<DataGrid.Columns>
<DataGridTemplateColumn Header="AutoCompleteColumn" CellTemplate="{StaticResource AutoCompleteTemplate}"/>
<DataGridCheckBoxColumn Header="CheckBoxColumn"/>
</DataGrid.Columns>
if the columns in the Datagrid are created dynamically, then you may need to create the column at the AutoGeneratingColumn (use interactiontrigger for MVVM) event based on some conditions that you have. Create a DataGridTemplateColumn and set the CellTemplate by finding from the resources.
Upvotes: 1