Radial Menu and Passing parameter

2 posts, 0 answers
  1. Ahamd
    Ahamd avatar
    2 posts
    Member since:
    Jan 2012

    Posted 30 May 2015 Link to this post

    Dear All;

     

    I tried a radial menu and it's working ok, but i failed to pass parameter from a textblock value using 

    CommandParameter

    when i pass static text, it's working, not when using a value from the textblock

    my code is

    1.<TextBlock x:Name="txtTest" Canvas.Left="83" TextWrapping="Wrap" Text="Hello" Canvas.Top="19"/>       
    2.            <Primitives:RadRadialMenu x:Name="mnuShops" Height="108" Width="102"  RenderTransformOrigin="0.506,0.494" Canvas.Top="-126" Canvas.Left="-132" FontSize="16">
    3.                <Primitives:RadialMenuItem x:Name="radialMenuItem" Header="FirstNode"  Command="{Binding FirstCommand, Source={StaticResource Commands}}" CommandParameter="{Binding Text, ElementName=txtTest}"/>
    4.                <Primitives:RadialMenuItem Header="Second Node"/>          
    5.            </Primitives:RadRadialMenu>

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 03 Jun 2015 Link to this post

    Hi Ahamd,

    You are correct. The CommandParameter does not support such kind of binding. 

    Please keep in mind that the RadialMenuItem is not a DependencyObject. This means that ordinary binding will not work. 

    You have two options to bind the CommandParameter property. First is to use StaticResource binding similar to this:

    <Page.Resources>
        <local:CustomItemCommand x:Key="customCommand" />
        <local:ViewModel x:Key="viewModel" />
    </Page.Resources>
     
    <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="0 40 0 0">
         
        <Primitives:RadRadialMenu DataContext="{StaticResource viewModel}">
            <Primitives:RadialMenuItem Header="Binding"
                                       Command="{StaticResource customCommand}"
                                       CommandParameter="{Binding Source={StaticResource viewModel}, Path=TestString}" />
        </Primitives:RadRadialMenu>
    </StackPanel>
    The other approach would be to use a custom attached property.

    I hope this information is helpful. Do not hesitate to contact us again if you need any further assistance.

    Regards,
    Pavel R. Pavlov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top