Silverlight Cascading Combobox
Posted
by lidermin
on Stack Overflow
See other posts from Stack Overflow
or by lidermin
Published on 2010-04-23T13:01:38Z
Indexed on
2010/04/23
13:03 UTC
Read the original article
Hit count: 247
silverlight-3.0
Hi, I have an issue trying to implement cascading comboboxes on Silverlight 3. I have two comboboxes:
- Product Type
- Sub Cathegory
The user need to select the Product type, and based on his selection, the second combobox must load the sub cathegories.
Binding the first combobox is a piece of cake:
<ComboBox x:Name="cmbProductType" Margin="11,2,8,5" MaxDropDownHeight="100" Grid.Column="1 />
cmbProductType.ItemsSource = objFactory.ProductTypes;
objFactory.Load(objFactory.GetProductTypesQuery());
My issue is trying to load the second combobox based on the first seleccion. I tryied to implement the SelectionChanged event on the first combobox, but it didn't worked for me:
private void cmbProductType_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
FactoryDS objFactory = new FactoryDS();
cmbSubCat.ItemsSource = objFactMetas.Campos;
objFactory.Load(objFactory.GetSubCathegoryQuery(((SybCathegroy)cmbProductType.SelectedItem).Id));
}
How should I do this? (I'm new on Silverlight). thanks in advance.
© Stack Overflow or respective owner