I have assigned ItemsSource property of first ListBox 'ListBox1' as the ItemsSource of another ListBox namely 'ListBox2' . If I set ListBox2's ItemsSource as null, then I am unable to add any Items further to ListBox1's ItemsSource.
Below is the xaml snippet,
<ListBox VerticalAlignment="Top" HorizontalAlignment="Center" Width="150" Margin="0 25 0 0"
x:Name="ListBox1" ItemsSource="{Binding Coll,Mode=TwoWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding _Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox VerticalAlignment="Top" HorizontalAlignment="Center" Width="150" Margin="0 25 0 0"
x:Name="ListBox2" ItemsSource="{Binding Path=ItemsSource,ElementName=ListBox1,Mode=TwoWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding _Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
In Code behind, I set the ItemSource of ListBox2 as null on button click like below,
ListBox2.SetCurrentValue(ListBox.ItemsSourceProperty, null);
Once this is done, I tried to add Items to ListBox1's "Coll" collection, but throws NRE that "Coll" is null.
Any suggestions plz.
Regards, Dinesh Kumar P