Как привязать значения listview в зависимости от выбранного элемента combobox?
Привет все что я хочу привязать мой список зависит от выбранного элемента combobox вот мой код
<StackPanel Orientation="Horizontal" > <ComboBox Name="cmbID" Width="150" Margin="10" Height="30" SelectedItem="{Binding CmbSelected,Mode=TwoWay}" DisplayMemberPath="ID" ItemsSource="{Binding MyStudent,Mode=TwoWay}"/> <Button Name="btnGetDetail" Margin="10" Command="{Binding getDetails}" Content="Get Details" Height="30" Width="90"/> <TextBox Name="tbName1" Width="90" Height="30" Text="{Binding ElementName=cmbID,Path= SelectedItem.Sub}"></TextBox> </StackPanel>
In Above code i am binding my combobox to one observable collection and want to bind my ListView to selected item of combobox below is my code
<ListView.View > <GridView x:Name="grdStudentDetails"> <GridViewColumn Header="ID" DisplayMemberBinding="{Binding ElementName=cmbID,Path=SelectedItem.ID}" Width="30"/> <GridViewColumn Header="Name" DisplayMemberBinding="{Binding ElementName=cmbID,Path =SelectedItem.Name}" Width="100"/> <GridViewColumn Header="RollNum" DisplayMemberBinding="{Binding ElementName=cmbID,Path=SelectedItem.RollNum}" Width="100"/> <GridViewColumn Header="Subject" DisplayMemberBinding="{Binding ElementName=cmbID,Path=SelectedItem.Sub}" Width="100"/> <GridViewColumn Header="PhNumber" DisplayMemberBinding="{Binding ElementName=cmbID,Path=SelectedItem.PhNum}" Width="100"/> </GridView> </ListView.View> </ListView>
I am not able to find where I am doing mistake even I bind my text box with same binding it is working fine. please refer textbox just below my combobox's XAML.
Что я уже пробовал:
I am not able to find where I am doing mistake even I bind my text box with same binding it is working fine. please refer textbox just below my combobox's XAML.
sumitk.cadc
частный студент cmbSelcted;
студенческие общественные CmbSelected
{
get { return cmbSelcted; }
set { cmbSelcted = value; OnPropertyChanged("CmbSelected"); }
}
public ObservableCollection<student> MyStudent
{
get { return myStudent; }
set { myStudent = value; OnPropertyChanged("MyStudent"); }
}