简体   繁体   中英

AutoSuggestBox in DataGrid?

My application is using a DataGrid. Some of the fields in the DataGrid are editable.

Rather than have the user type anything they want into the editable fields, I want to use an AutoSuggestBox. I have used AutoSuggestBox controls on their own, but I don't know how to incorporate one into a DataGrid. Is this possible?

You can put the AutoSuggestBox by custom CellTemplate from Column like below:

<controls:DataGrid ItemsSource="{x:Bind lists}"
          AutoGenerateColumns="False">​
                <controls:DataGrid.Columns>​
                    <controls:DataGridTemplateColumn Header="Edit">​
                        <controls:DataGridTemplateColumn.CellTemplate>​
                            <DataTemplate>​
                                <AutoSuggestBox PlaceholderText="hello" Width="100"></AutoSuggestBox>​
                            </DataTemplate>​
                        </controls:DataGridTemplateColumn.CellTemplate>​
                    </controls:DataGridTemplateColumn>​
                </controls:DataGrid.Columns>​
</controls:DataGrid>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM