Dharshini

Dharshini

  • 2k
  • 24
  • 22.2k

Binding DataGrid Details to Selected Item in a combobox

Mar 15 2013 7:39 AM
I have a `combobox` and a `datagrid` in my application. The datagrid has its itemsSource from its collectionViewSource resource key(using Entity Framework) and there are three `ComboBoxItem`'s inside the combobox as warning/error/exception as shown in the image- http://tempuri.org/tempuri.html


How to display the selecteditem row details on the datagrid when the respective `ComboxBoxitem` is selected.
XAML for ComboBox


<ComboBox SelectedItem="{Binding DetailsViewSource.Type}" 
     SelectedValuePath="{Binding ElementName=dataGrid1,Path=SelectedItem.Type,Mode=OneWay}"
      Grid.Column="1" Height="32" HorizontalAlignment="Left" Name="comboBox1" >
    <ComboBoxItem Content="Warning"/>
    <ComboBoxItem Content="Error"/>
    <ComboBoxItem Content="Exception"/>
    </ComboBox>


XAML for Datagrid

 <DataGrid AutoGenerateColumns="False" 
 Foreground="DarkBlue" EnableRowVirtualization="True" Height="auto"
 HorizontalAlignment="Left" ItemsSource="{Binding}" Name="dataGrid1">



Kindly help. Thanks