0
votes

I have a datagrid which has a combobox in celltemplate

   <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Path=List,Mode=TwoWay}">
        <DataGrid.Columns>
            <DataGridTextColumn Header="ID" Binding="{Binding Path=ID,Mode=TwoWay}"></DataGridTextColumn>
            <DataGridTemplateColumn Header="Names" >
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ComboBox SelectedItem="{Binding Path=Name,Mode=TwoWay}"
                                  SelectedValuePath="Type"                                      
                                  ItemsSource="{Binding Path=Names,Mode=TwoWay,Source={StaticResource someSource}}"></ComboBox>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>

in the above code when i change the Name from the combobox in datagrid..the itemssource list should change??How to do that??

1
what do you mean by changing the name from combobox? u mean selecting different names from combobox? and what change you want in your itemssource??Vishal

1 Answers

0
votes

Based on the title I'm assuming you mean change the itemsSource of your Datagrid. This is a weird requirement, but this should work

<ComboBox DropDownClosed="ComboBox_DropDownClosed" 
    SelectedItem="{Binding Path=Name,Mode=TwoWay}"
    SelectedValuePath="Type"                                      
    ItemsSource="{Binding Path=Names,Mode=TwoWay,Source={StaticResource someSource}}">     
</ComboBox>

private void ComboBox_DropDownClosed(object sender, EventArgs e)
{
    myGrid.ItemsSource = myOtherList;
}