This is a migrated thread and some comments may be shown as answers.

Binding to CheckState with Toggle.On throws exception

1 Answer 98 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
mckhendry
Top achievements
Rank 1
mckhendry asked on 11 Mar 2012, 08:55 PM
Using the TreeView, I want to have a list of items that can be checked and reordered. I'm using an ItemContainerStyle for binding the CheckState, and a Converter to convert to/from a bool value in my viewmodel. The issue I'm having is when loading the list where some of the items should be defaulting to a CheckState of Toggle.On. If all items have a CheckState of Toggle.Off then there is no exception.

The details of the exception are as follows:

Microsoft JScript runtime error: Unhandled Error in Silverlight Application Object reference not set to an instance of an object. at Telerik.Windows.Controls.TreeView.WeakReferenceKey`1..ctor(T item)
at Telerik.Windows.Controls.RadTreeView.StoreCheckState(RadTreeViewItem container, Object item, ToggleState newCheckState)
at Telerik.Windows.Controls.RadTreeViewItem.OnCheckStatePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty property)
at MS.Internal.FrameworkCallbacks.InvalidateProperty(IntPtr nativeTarget, UInt32 propertyId)

I've created a sample project which easily reproduces this issue (click on the second button to see the exception), and can be downloaded from http://kelly.whitepdx.com/RadControlsSilverlightApp1.zip

NOTE: I've been able to recreate this issue with the following releases:
2011.2.712.1040
2011.2.920.1040
2011.3.1220.1040

I'm unsure of how to fix this, or what method should be used instead.

Kelly White - Microsoft MVP Windows Phone Development

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 13 Mar 2012, 01:00 PM
Hi,

I'm posting my reply to your support ticket in this forum thread because other other users could find it useful too:

There is an issue with Telerik RadTreeView when using style bindings to CheckState in Silverlight. We've already addressed that issue and will try to provide a fix ASAP. You can track the related item in our public issue tracking system (PITS) and vote for its resolution via following page: http://www.telerik.com/support/pits.aspx#/details/Issue=10031 

Also, I've modified your example to use ContainerBindings instead. I'm using your DLLs version and everything seems correct.
Finally, I would like to advise you not to use CheckState bindings and build in tri-state functionality. In that case the bindings take precedence over the tri-state logic which could be unexpected in some scenarios. Instead, the best bug-free approach in my personal opinion would be to implement the tri-state logic by yourself inside the view model.

Greetings,
Hristo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TreeView
Asked by
mckhendry
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or