Reputation: 6120
I have 2 ListBox ( "Types" and "Products") "Types" gets all its data from database. I want to list in "Products" which is type selected in "Types" listbox.
I want to do it in the WPF. Can you help me? Thank you for your attention
Upvotes: 0
Views: 133
Reputation: 22445
i assume that types is somewhat related to products. then you can do the following. (you have to set the right DataContext of course :)
public class Types
{
public List<Product> MyProducts {get; set;}
}
xaml.cs or mvvm
{
public List<Types> MyTypesCollection {get; set;}
}
xaml
<ListBox x:Name=lstTypes ItemSource="{Binding MyTypesCollection}" />
<ListBox ItemsSource="{Binding ElementName=lstTypes, Path=SelectedItem.MyProducts}"/>
Upvotes: 2