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

RadMenuItem not calling converter unless binding is set to two way

3 Answers 105 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 02 Feb 2011, 09:45 PM
Hello,

I have a problem with the RadContextMenu.  I have an RadMenuItem's IsEnabled property bound to an object and am using a converter to change that into a bool.  However, the converter never gets called unless I use TwoWay binding which is not possible.  Any ideas about this?  Below is my sample:

<telerik:RadContextMenu.ContextMenu>
                                        <telerik:RadContextMenu>
                                            <telerik:RadMenuItem Header="TEXT UNIT" FontSize="12" IsEnabled="{Binding RadioSystemType, Converter={StaticResource Enable_Texting_SysType}}" Command="{Binding Main.AddConversation, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="{Binding MakeKeyBindable, Mode=OneWay}" Click="TextUnitorGroup_Click"/>
                                            <telerik:RadMenuItem Header="SETTINGS" FontSize="12" CommandParameter="{Binding MakeKeyBindable, Mode=OneWay}" Command="{Binding Main.EditUnitCommand, Mode=OneWay, Source={StaticResource Locator}}"/>
                                            <telerik:RadMenuItem Header="FOLLOW UNIT" FontSize="12">
                                                <telerik:RadMenuItem Header="TRACK IN WINDOW 1" FontSize="12" CommandParameter="{Binding Mode=OneWay}" Command="{Binding Main.FollowUnitWindow1Command, Mode=OneWay, Source={StaticResource Locator}}"/>
                                                <telerik:RadMenuItem Header="TRACK IN WINDOW 2" FontSize="12" CommandParameter="{Binding Mode=OneWay}" Command="{Binding Main.FollowUnitWindow2Command, Mode=OneWay, Source={StaticResource Locator}}"/>
                                            </telerik:RadMenuItem>
                                            <telerik:RadMenuItem Header="NEAREST ASSETS" FontSize="12" Click="RadMenuItem1_Click"/>
                                            <telerik:RadMenuItem Header="ADD UNIT" FontSize="12" Command="{Binding Main.AddUnitCommand, Mode=OneWay, Source={StaticResource Locator}}"/>
                                            <telerik:RadMenuItem Header="DELETE UNIT" FontSize="12" Command="{Binding Main.RemoveUnitCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="{Binding MakeKeyBindable, Mode=OneWay}"/>           
                                        </telerik:RadContextMenu>               
                                    </telerik:RadContextMenu.ContextMenu>

3 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 02 Feb 2011, 09:47 PM
BTW I don't believe I understand how to use your Format Code Block.  I want to try and aid you in any way possible to help me so please a brief explanation.

Thanks,
Adam Burdette
0
Accepted
Hristo
Telerik team
answered on 02 Feb 2011, 10:59 PM
Hello Adam,

When Binding the Command property its CanExecute status changes IsEnabled property. So when CanExecute is changed IsEnabled is also changed. But this change clears the Binding that you have set in XAML. This can be fixed only in WPF 4.
So you have 2 options - either use two way Bindings or if you want to disable the menu item use the Command CanExecute event and return false in its event args.

Let us know if you need more information.

Kind regards,
Hristo
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
mkk09
Top achievements
Rank 1
answered on 01 Feb 2021, 11:57 AM
what did you mean by BTW?
Tags
ContextMenu
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Hristo
Telerik team
mkk09
Top achievements
Rank 1
Share this question
or