I want to use CheckListBox and bind its ItemsSource to an ObservableCollection.
This is the XAML:
When I click the Add button in my UI, it crashes in the AddClick method with the following error:
Thanks!
Dina
This is the XAML:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tk="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<Button Click="AddClick">Add</Button>
<tk:CheckListBox ItemsSource="{Binding ListItems}"></tk:CheckListBox>
</StackPanel>
</Window>
And this is the code-behind:namespace WpfApplication1 { ///<summary>/// Interaction logic for MainWindow.xaml///</summary>publicpartialclass MainWindow : Window { public ObservableCollection<string> ListItems { get; set; } public MainWindow() { InitializeComponent(); this.DataContext = this; ListItems = new ObservableCollection<string>(); } privatevoid AddClick(object sender, RoutedEventArgs e) { ListItems.Add("string"); } } }
The runtime has encountered a fatal error. The address of the error was at 0xeb40f4f4, on thread 0x1414. The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.Is this a bug or am I doing something wrong? My code is pretty straight forward. If I change the CheckListBox to regular ListBox everything works...
Thanks!
Dina