Quantcast
Viewing all articles
Browse latest Browse all 18858

Add Items to Activity Designer ComboBox depending on selection of another ComboBox

Hello :)

This is my first post here.

I have an activity designer with a collapsed and expanded view. I'm using a Content Presenter to show 2 como boxes, here is a code snippet for the Expanded or Collapsed Style:

<!--Style for Content Presenter Collapsed or Expanded--><Style x:Key="ExpandOrCollapsedStyle"
               TargetType="{x:Type ContentPresenter}"><Setter Property="ContentTemplate"
                    Value="{DynamicResource Collapsed}"/><Style.Triggers><DataTrigger Binding="{Binding Path=ShowExpanded}"
                             Value="true"><Setter Property="ContentTemplate"
                            Value="{DynamicResource Expanded}"/></DataTrigger></Style.Triggers></Style>


I'm populating a ComboBox from an Entity Data Model, using an ObservableCollection of ComboBox Items, this is the code of that combo Box:

<ComboBox
Name="Service_Items"
ItemsSource="{Binding cbSI}"
SelectedValue="{Binding Path=ModelItem.SI_Name, Mode=TwoWay, Converter={StaticResource comboBoxItemConverter}}"                    SelectionChanged="Service_Items_SelectionChanged"/>


And the code Behind:

public ObservableCollection<ComboBoxItem> cbSI 
{ get; set; }
...

InitializeComponent();
cbSI = new ObservableCollection<ComboBoxItem>();
var items = from c in ctx.ServiceItemConfig
            select c.SI_Name;

foreach (var i in items)
{
cbSI.Add(new ComboBoxItem { Content = i });
}

What I want is: when I select a value on the first ComboBox the second Combo Box will populate as the same way of the first, but using the selected value in a linq to entities query.

I'm using an observable collection for the second one and adding items at the same way (I'm not sure how I'm going to use the selected value) , but nothing happens, when I select one item on the first combo the eventhandler instantiates an observable collection and add items to this but the second combo box doesn't show me any item. Anyone can help me?

Greetings. 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>