<
Grid
Grid.Row
=
"1"
Margin
=
"12,0,12,0"
>
<
ListBox
x:Name
=
"ProfileList"
DoubleTap
=
"ProfileList_DoubleTap"
ItemsSource
=
"{Binding}"
>
<
ListBox.ItemTemplate
>
<
DataTemplate
>
<
Grid
Tag
=
"{Binding}"
>
<
telerik:RadContextMenu.ContextMenu
>
<
telerik:RadContextMenu
Opening
=
"ContextMenu_Opening"
Background
=
"{StaticResource PhoneContrastBackgroundBrush}"
>
<
telerik:RadContextMenuItem
x:Name
=
"PinToStart"
IsEnabled
=
"False"
Content
=
"Pin to Start"
Tap
=
"PinToStart_Tap"
/>
</
telerik:RadContextMenu
>
</
telerik:RadContextMenu.ContextMenu
>
Even though IsEnabled is explicity let to False here, I can still click the menu item. If I set .IsEnabled in codebehind, it doesn't change anything either.
16 Answers, 1 is accepted
Thank you for reporting this!
We verified the isssue and we will release an internal build next week with a fix for the issue. I added 1000 Telerik points to your account.
Kind regards, Valentin.Stoychev
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
For the first time, the state is reflected correct -> CanExecute == true -> Menu enabled or CanExecute == false-> Menu disabled.
But when I open the menu the second time and CanExecute returns false, then menu is still enabled.
Shouldn't it reflect the correct state?
Thanks
Eric
(V2012.1.214.2040)
Yes, you are right that when the return value of CanExecute changes, this should be reflected in the ContextMenuItem. We have already fixed this and you can download the fix with our latest internal build:
RadControls_for_WindowsPhone_2012_1_0221_DEV_hotfix, which is available from the Downloads section of your account.
Thank you for your time. I have added 1000 points to your account for bringing this to our attention.
Kind regards,
Todor
the Telerik team
Was able to get the correct hotfix.
But it seems there is a new problem.
When I used the command as this:
Command="{StaticResource DeleteCommand}" CommandParameter="{Binding}"
the parameter in CanExecute is always null.
Command="{StaticResource DeleteCommand}"Without specifiying the parameter, I get the param of type RadDataBoundListBoxItem.
But now I'm getting an error when I'm calling the delegate/event CanExecuteChanged:
System.NullReferenceException was unhandled
Message=NullReferenceException
StackTrace:
at Telerik.Windows.Controls.RadContextMenu.GetCurrentManipulationSource()
at Telerik.Windows.Controls.RadContextMenuItem.GetActualCommandParameter()
at Telerik.Windows.Controls.RadContextMenuItem.UpdateIsEnabled()
at Telerik.Windows.Controls.RadContextMenuItem.OnCommandCanExecuteChanged(Object sender, EventArgs e)
at MyApp.Helper.CommandBase`1.OnCanExecuteChanged(EventArgs e)
So, I think something is mixed up now. (see also your example here: http://www.telerik.com/community/forums/windows-phone/trial-feature-reminder/reminder-and-commands.aspx#1997325
Thanks
Eric
Thank you for writing.
I managed to reproduce the exception you described and the issue has been fixed. The new dlls will be available for download as an internal build later today.
Please write again if you need further assistance.
Victor
the Telerik team
I have still problems with the latest hotfix version (301).
I defined the ContextMenuItem for a RadJumpList like this:
<telerikPrimitives:RadContextMenuItem Content="Download" Command="{StaticResource DownloadCommand}" CommandParameter="{Binding}"/>
So I expect as parameter for CanExecute a object of type RadDataBoundListBoxItem
But the param is always null.
Could you tell me why the param is always null? I thought this was fixed.
Thanks
Eric
Thank you for writing.
In order for the command parameter to be a RadDataBoundListBoxItem, the CommandParameter property should not be set. When it is not set, the context menu should automatically pass the visual item as command parameter.
Please write again if you need further assistance.
Victor
the Telerik team
Pat
Thank you for writing.
We decided that the IsEnabled property should be controlled from one point only. This point is determined according to whether there is a command set or not. If a command is set, the command will always have priority and it will be responsible for managing the IsEnabled property. This can be done with the CanExecute() method that every command has. If CanExecute() returns false, the menu item will be disabled, if it returns true, the item will be enabled. If no command is set, the IsEnabled property will be available through XAML or C#.
Please write again if you have other questions.
Kind regards,
Victor
the Telerik team
I am having just a tapped event on RadContextMenuItem (and not a command), but the IsEnabled property is not being respected. I dont want to write a command for achieving the enabled/disabled state. Can you please look into this?
<
telerikPrimitives:RadContextMenuItem Content="pin to start" Tapped="Pin_Clicked" IsEnabled="False"/>
Thanks for writing.
The Tapped event will be marked as obsolete from this release and will removed subsequently because since the Mango update, a system Tap event was introduced. Please use the Tap event instead.
Victor
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
As suggested, I have moved to Tap event instead of Tapped event, however setting IsEnabled=False is still not being respected. Please resolve this or unfortuantely I will have to move back to silverlight context menus.
<
telerikPrimitives:RadContextMenuItem Content="pin to start" Tap="Pin_Clicked" IsEnabled="False"/>
Thank you for the feedback.
This is a bug in the context menu and it will be fixed in the upcoming Q2 2012 release (next week on June 6-th).
Please write again if you have more feedback to share or if you need assistance with our controls.
Your Telerik points have been updated.
All the best,
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Also thank you for working on a fix in the upcoming release!
Instead of doing this from code behind (assuming 0th item needs to be enabled/disabled):
((RadContextMenuItem)menu.Items[0]).IsEnabled = <condtion> ?
true
:
false
;
Do this:
((RadContextMenuItem)menu.Items[0]).Command = <condition> ?
null
:
new
NonExecutableCommand();
public
class
NonExecutableCommand : ICommand
{
public
bool
CanExecute(
object
parameter)
{
return
false
;
}
public
event
System.EventHandler CanExecuteChanged;
public
void
Execute(
object
parameter) { }
}
Thank you for understanding and for posting the workaround, other people will definitely find it useful if they run into this issue.
Kind regards,Victor
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>