Hai am using wpf list box, i cannot able to clear the list when am calling the reload data function, i just want to reload new data at runtime,while page loading it loads the data correctly, when i refresh the new data is fetched in itemsource i can see that in debug mode, but no new data in listbox, old data remains in the list, i cant even clear, when i call list.items.clear(), it throws exception and app crashes, i tried lot ways, is ther any problem in my XAML binding, the following is my code.
<DataTemplate x:Key="listBoxTemplate">
<StackPanel Margin="3">
<DockPanel >
<TextBlock FontWeight="Bold" Text="{Binding Name}" DockPanel.Dock="Left" Margin="5,0,10,0"/>
<TextBlock Text=" " />
<TextBlock Text="{Binding Percnt}" Foreground="Green" FontWeight="Bold" />
</DockPanel>
</StackPanel>
</DataTemplate>
My listbox
<ListBox Height="898" Name="lstEntity" Width="291" ItemTemplate="{StaticResource listBoxTemplate}" SelectionChanged="lstEntity_SelectionChanged"/>
Binding code
lstEntity.ItemsSource = sei.getNames();
getNames() function just returns the data as list,nothing special code in that, How to resolve this.