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

Radial Menu and Passing parameter

1 Answer 69 Views
RadialMenu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ahamd
Top achievements
Rank 1
Ahamd asked on 30 May 2015, 12:27 PM

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>

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 03 Jun 2015, 08:02 AM
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
Tags
RadialMenu
Asked by
Ahamd
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or