This project has moved. For the latest updates, please go here.

CheckComboBox with MVVM

Mar 5, 2013 at 10:19 AM
Edited Mar 5, 2013 at 10:23 AM
Can I use checkcombobox control (free version) using MVVM?

I had used it earlier and it worked fine with the earlier versions 1.7. Now, since the update to 1.9, it is not working. Giving me the error while clearing itemsource property for a particular scenario..
Developer
Mar 5, 2013 at 11:58 AM
What is the scenario where you are getting an error while cleaning the itemsSource ? Can you provide a code snippet ?
Mar 7, 2013 at 11:22 AM
Hi BoucherS,

Thanks for showing interest in my post.

Actually I have a tabcontrol which has say 2 tabs.

I have a list of objects "X" on tab 1.
I m using CheckComboBox in the 2nd tab. I am binding ItemSource property to a observable collection of X objects.

However, when user switches from 1st tab to 2nd tab, I m clearing the observable collection, so that I can fill the latest data from tab 1, into the collection.

I m getting the error as below while doing so:

The runtime has encountered a fatal error. The address of the error was at 0xca341114, on thread 0xf0c. 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.
Developer
Mar 7, 2013 at 1:03 PM
Maybe the following link could help you ;
http://stackoverflow.com/questions/1861475/marshal-struct-problem-with-c-sharp

I made a simple sample to test the "Clear" of the CheckComboBox.ItemsSource. Everything worked well. Here's the sample :

XAML :
<Window x:Class="TestToolkit.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
    xmlns:local="clr-namespace:TestToolkit"
    x:Name="_demo"
    Title="MainWindow" Height="800" Width="1200" >
<Grid>
   <xctk:CheckComboBox ItemsSource="{Binding PersonList, ElementName=_demo }" DisplayMemberPath="Name"/>
</Grid>
</Window>

C# :
public class Person : DependencyObject
{
public string Name
{
  get;
  set;
}

public int ID
{
  get;
  set;
}
}

public partial class MainWindow : Window
{
ObservableCollection<Person> _personList = new ObservableCollection<Person>();

public ObservableCollection<Person> PersonList
{
  get
  {
    return _personList;
  }
}

public MainWindow()
{
  _personList.Add( new Person() { Name="Bob", ID=1});
  _personList.Add( new Person() { Name="Tom", ID=2});
  _personList.Add( new Person() { Name="Mark", ID=3});
  _personList.Add( new Person() { Name="Brian", ID=4});
  _personList.Add( new Person() { Name="Carey", ID=5});
  _personList.Add( new Person() { Name="Scott", ID=6});

  InitializeComponent();
}
protected override void OnKeyDown( KeyEventArgs e )
{
  base.OnKeyDown( e );

  if( e.Key == Key.A )
  {
    PersonList.Clear();
    PersonList.Add( new Person() { Name="Alan", ID=5});
    PersonList.Add( new Person() { Name="Kevin", ID=6});
    e.Handled = true;
  }
}
So when the Key_A is pressed, the list used for the binding of the CheckComboBox is cleared and new entries are made. CheckComboBox has been updated without errors.
Mar 26, 2013 at 1:34 PM
BoucherS wrote:
Maybe the following link could help you ;
http://stackoverflow.com/questions/1861475/marshal-struct-problem-with-c-sharp
From what I can tell, that link's really only useful if you've got an issue with marshalling structs. I can't speak for prasad1210, but that's certainly not my issue, and I'm getting the same error message he is.
I made a simple sample to test the "Clear" of the CheckComboBox.ItemsSource. Everything worked well.
I just ran your sample code. Everything works just fine until I hit 'a', and then I get this, when PersonList.Clear() executes:
"FatalExecutionEngineError was detected
Message: The runtime has encountered a fatal error. The address of the error was at 0x691819d4, on thread 0x1c34. 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."

I grabbed the most recent version of the Extended WPF Toolkit using NuGet. I'm not sure if that makes a difference or not.
Developer
Mar 28, 2013 at 5:36 PM
Hello,
I downloaded the v1.9 of the Toolkit to run the current sample and got the same crash as you said.
When using v2.0, it is fixed.
Please wait for the next version of the toolkit.

Thank you
Jul 11, 2013 at 12:46 PM
I can confirm that v2.0 does fix this issue for me. (Like 1.9, I grabbed it from NuGet.)