I have two ListBoxes, both use Extended SelectionMode. The ItemsSource of the first is a List, and uses a datatemplate. I'm trying to use an aggregation of some property from the first as the itemssource for the second. For example:
public class MultiAppPropertyAggregator : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
IList<SomeObject> selectedItems = value as IList<SomeObject>;
Dictionary<string, string> bundles = new Dictionary<string,string>();
foreach(SomeObject myobj in selectedItems) {
foreach(KeyValuePair<string,string> name in myobj.Names) {
selectedItems.Add(name.Key, name.Value);
....
<ListBox x:Name="lstApplication" ItemsSource="{Binding}" SelectionChanged="lstApplication_SelectionChanged" SelectionMode="Extended" />
<ListBox x:Name="lstBundles" ItemsSource="{Binding ElementName=lstApplication,Path=SelectedItems,Mode=OneWay,Converter={StaticResource MultiAppPropertyAggregator}}" ItemTemplate="{StaticResource DictionaryList}" SelectedValuePath="Key" SelectionMode="Extended" />
So the objects in the first list contain a property of type Dictionary. I want to add all items in the dictionaries of all selected items in the first list to the second list.
The converter seems to be called on initial load, then not again after that and I end up with an empty second listbox. Am I missing something?