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

Error setting RadContextMenu.ItemContainerStyle in SL4

2 Answers 99 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brandon Strevell
Top achievements
Rank 1
Brandon Strevell asked on 25 Mar 2010, 05:23 PM
I'm getting a run-time error "Set property '' threw an exception" when I set the ItemContainerStyle of a RadContextMenu using the Silverlight 4 RC 2010.1 309.  Am I doing something wrong?

    <UserControl.Resources> 
        <local:DataItemCollection x:Key="ItemsSource"
            <local:DataItem Text="Item 1"
                <local:DataItem Text="Item 1.1" /> 
                <local:DataItem Text="Item 1.2" /> 
                <local:DataItem Text="Item 1.3" /> 
            </local:DataItem> 
            <local:DataItem Text="Item 2"
                <local:DataItem Text="Item 2.1" /> 
                <local:DataItem Text="Item 2.2" /> 
                <local:DataItem Text="Item 2.3" /> 
            </local:DataItem> 
            <local:DataItem Text="Item 3"
                <local:DataItem Text="Item 3.1" /> 
                <local:DataItem Text="Item 3.2" /> 
                <local:DataItem Text="Item 3.3" /> 
            </local:DataItem> 
        </local:DataItemCollection> 
    </UserControl.Resources> 
    <Grid> 
        <telerikNavigation:RadContextMenu ItemsSource="{Binding Source={StaticResource ItemsSource}}" > 
            <telerikNavigation:RadContextMenu.ItemContainerStyle> 
                <Style TargetType="telerikNavigation:RadMenuItem"
                    <Setter Property="Header" Value="{Binding Text}"/> 
                    <Setter Property="ItemsSource" Value="{Binding Children}"/> 
                </Style> 
            </telerikNavigation:RadContextMenu.ItemContainerStyle> 
        </telerikNavigation:RadContextMenu> 
    </Grid> 

System.Windows.Markup.XamlParseException occurred
  Message=Set property '' threw an exception. [Line: 35 Position: 53]
  LineNumber=35
  LinePosition=53
  StackTrace:
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
  InnerException: System.NotSupportedException
       Message=Cannot set read-only property ''.
       StackTrace:
            at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
            at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, XamlPropertyToken inProperty, XamlQualifiedObject& inValue)
       InnerException: 

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 26 Mar 2010, 11:54 AM
Hello Brandon Strevell,

Silverlight 4 doesn't support Bindings in Style setter.
<Setter Property="Header" Value="{Binding Text}"/>

With the RC release the parser now throws exception (in SL 3 it was ignored).
We have workaround for this - ContainerBindingCollection where you specify Binding for each property of the container (in this case RadMenuItem) that have to be bound.
You can see an example with source code here:
http://demos.telerik.com/silverlight/#Menu/DataBinding

Let us know if you need more information.

Kind regards,
Hristo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brandon Strevell
Top achievements
Rank 1
answered on 26 Mar 2010, 02:40 PM
Thank you, that makes perfect sense.
Tags
General Discussions
Asked by
Brandon Strevell
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Brandon Strevell
Top achievements
Rank 1
Share this question
or