I have made DB with a table and 2 fields on that table. ID and Name SQL Server.
My WPF Application has a combo box and i bind the Table.Name to the combobox.
Then i bind a DataGrid to the Table itself.
So what i have is when choosing an item on the combobox on the datagrid i get is as "selected", i wish it to display on the item i choose.
Thanks
eg picture below, i choose first, but i want only the data of first to be displayed and not selected.
Try to bind the table to your combobox and then bind the datagrid to the combobox.SelectedItem I don't have a xaml editor but you will have something like this:
<ComboBox x:Name="cbo_MyCbo" ItemsSource="{Binding Table}" DisplaMemberPath="Name">
<!--DataTemplate If Needed-->
</ComboBox>
<Datagrid x:Name="dtg_MyDtg" ItemsSource="{Binding ElementName=cbo_MyCbo, Path=SelectedItem}">
<!-- column def-->
</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.