Remarks
UXMenuItem implements both ICommandSource and INavigationSource that allows both commanding and navigation using UXMenuItem.
You can do commanding through Command, CommandTarget and CommandParameter properties, and navigation using NavigateUri and TargetName properties. To learn more about commanding, see Commanding Overview. To learn about navigation, see Navigation Overview.
Example
Definition
public class UXMenuItem : ISHeaderedSelectionControl,
Summary
The following table summarizes the members exposed in this class.
Public Constructors
UXMenuItem Constructor() | Initializes a new instance of the UXMenuItem class. |
Public Properties
BoundaryOffset | Gets or set the minimum boundary offset. |
ClickLatency | Gets or sets the latency, in seconds, before the click action is executed. |
Command | Gets or sets the command to invoke when this button is clicked. |
CommandCannotExecute | Gets or sets the UI behavior when the associated Command cannot be executed. |
CommandParameter | Gets or sets the parameter to pass to the Command property. |
CommandTarget | Gets or sets the element on which to raise the specified command. |
ContentElement | Gets the content element. |
ContentMargin | Gets or sets the outer margin of content element. |
ContentPresenter | Gets the content presenter. |
DefaultCheckedImageSource | Gets or sets the checked image source. |
DisplayAnimation | Gets or sets a value that determines the display animation. |
EnableFadeInAnimation | Gets or sets a value that determines whether the fade animation is enabled. |
EnableFadeOutAnimation | Gets or sets a value that determines whether the fade animation is enabled. |
GroupName | Gets or sets the group name. |
HideAnimation | Gets or sets a value that determines the hide animation. |
HorizontalOffset | Gets or sets the distance between the left side of the Silverlight control and the left side of the popup. |
Icon | Gets or sets the source for the image. |
IconTemplate | Gets or sets the template to apply to Icon element. |
ImageHeight | Gets or sets the height of the image. |
ImageMargin | Gets or sets the margin of the image. |
ImageStretch | Gets or sets the image stretch mode. |
ImageWidth | Gets or sets the width of the image. |
IndicatorVisibility | Gets or sets the visibility of indicator element. |
InputGestureText | Gets or sets the input gesture text. |
IsCheckable | Gets or sets a value that determine whether the item is checkable. |
IsChecked | Gets or seta a value that determine whetehr the item is checked. |
IsEnabled | Gets or sets a value indicating whether the user can interact with the control. |
IsOpen | Gets or sets whether the popup is currently displaying on the screen. |
IsSelectable | Gets or sets a value that indicates whether the item is selectable. |
MenuElement | Gets the menu element. |
NavigateUri | Gets or sets the URI to navigate when this menu item is clicked. |
PreferredHorizontalDirection | Gets or sets the preferred horizontal direction. |
PreferredPosition | Gets or sets the preferred pop up positions. |
PreferredVerticalDirection | Gets or sets the preferred vertical direction. |
RootElement | Gets the root element. |
SlideDirection | Gets or sets a value that determine the slide direction when slide animation is used. |
StaysOpenOnClick | Gets or sets a value that determines whether menu stays open when the item is clicked. |
TargetName | Gets or sets the name of a target window or frame that will display the content specified by the NavigationUri property. |
VerticalOffset | Gets or sets the distance between the top of the Silverlight control and the top of the popup. |
Protected Properties
HideLatencyTimeout | Gets hide latency timeout. |
Product | Product Info. |
RequireUpdateCanExecute | Determines whether the command associated to this button require to be updated in the next call. |
ShowLatencyTimeout | Gets show latency timeout. |
Fields
BoundaryOffsetProperty | Identifies the BoundaryOffset dependency property. |
CheckedEvent | Identifies the Checked routed event. |
ClickEvent | Identifies the Click routed event. |
ClickLatencyProperty | Identifies the BusyLatency dependency property. |
CommandCannotExecuteProperty | Identifies the CommandCannotExecute dependency property. |
CommandParameterProperty | Identifies the CommandParameter dependency property. |
CommandProperty | Identifies the Command dependency property. |
CommandTargetProperty | Identifies the CommandTarget dependency property. |
ContentMarginProperty | Identifies the ContentMargin dependency property. |
DefaultCheckedImageSourceProperty | Identifies the ImageSource dependency property. |
DisplayAnimationProperty | Identifies the DisplayAnimation dependency property. |
EnableFadeInAnimationProperty | Identifies the EnableFadeAnimation dependency property. |
EnableFadeOutAnimationProperty | Identifies the EnableFadeAnimation dependency property. |
GroupNameProperty | Identifies the GroupName dependency property. |
HideAnimationProperty | Identifies the HideAnimation dependency property. |
HorizontalOffsetProperty | Identifies the HorizontalOffset dependency property. |
IconProperty | Identifies the ImageSource dependency property. |
IconTemplateProperty | Identifies the IconTemplate dependency property. |
ImageHeightProperty | Identifies the ImageHeight dependency property. |
ImageMarginProperty | Identifies the ImageMargin dependency property. |
ImageStretchProperty | Identifies the ImageStretch dependency property. |
ImageWidthProperty | Identifies the ImageWidth dependency property. |
IndicatorVisibilityProperty | Identifies the IndicatorVisibility dependency property. |
InputGestureTextProperty | Identifies the InputGestureText dependency property. |
IsCheckableProperty | Identifies the IsCheckable dependency property. |
IsCheckedProperty | Identifies the IsChecked dependency property. |
IsEnabledProperty | Identifies the IsEnabled dependency property. |
IsOpenProperty | Identifies the IsOpen dependency property. |
IsSelectableProperty | Identifies the IsSelectable dependency property. |
NavigateUriProperty | Identifies the NavigationUri dependency property. |
PreferredHorizontalDirectionProperty | Identifies the PreferredPosition dependency property. |
PreferredPositionProperty | Identifies the PreferredPosition dependency property. |
PreferredVerticalDirectionProperty | Identifies the PreferredVerticalDirection dependency property. |
ShowLatencyProperty | Identifies the ShowLatency dependency property. |
SlideDirectionProperty | Identifies the SlideDirection dependency property. |
StaysOpenOnClickProperty | Identifies the StaysOpenOnClick dependency property. |
TargetNameProperty | Identifies the TargetName dependency property. |
UncheckedEvent | Identifies the Unchecked routed event. |
VerticalOffsetProperty | Identifies the VerticalOffset dependency property. |
Public Methods
AttachEventHandlers() | Attach built-in event handlers to control templates. Call this method if necessary. |
DetachedEventHandlers() | Detach built-in event handlers from control templates. Call this method if necessary. |
Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
Hide() | Hide the context menu. |
InitializeTemplates() | Initializes control templates. |
OnApplyTemplate() | Builds the visual tree for the UXMenuItem when a new template is applied. |
Select() | Select the item. |
Unselect() | Unselect the current menu item. |
Protected Methods
ApplyBinding(DependencyObject, object) | Applies item binding for each generated element. |
ApplyStyle(DependencyObject, object) | Applies style for container element generated for each item. |
ChangeVisualState(bool) | Change Visual State. |
DoToggle() | Do toggle. |
GetContainerForItemOverride() | Creates or identifies the element that is used to display the given item. |
GoToCheckedState() | Go to checked state. |
GoToCheckedState(bool) | Go to checked state. |
GoToDisabledMouseOverState() | Go to disabled state. |
GoToDisabledMouseOverState(bool) | Go to disabled state. |
GoToPressedState() | Go to pressed state. |
GoToPressedState(bool) | Go to pressed state. |
GoToUncheckedState() | Go to unchecked state. |
GoToUncheckedState(bool) | Go to unchecked state. |
IsItemItsOwnContainerOverride(object) | Determines if the specified item is (or is eligible to be) its own container. |
OnChecked() | Raises Checked event. |
OnClicked(ISRoutedEventArgs) | Raises Click event. |
OnCommandChanged(ICommand, ICommand) | Invoked when the Command dependency property is changed. |
OnHeaderChanged(object, object) | Called when the value of the Header property changes. |
OnInitializeCommandDefault(ICommand) | Invoked when the Command is initialized. |
OnIsSelectedChanged(bool, bool) | |
OnItemsChanged(NotifyCollectionChangedEventArgs) | Called when the value of the System.Windows.Controls.ItemsControl.Items property changes. |
OnLostMouseCapture(MouseEventArgs) | Called before the System.Windows.UIElement.LostMouseCapture event occurs. |
OnMenuItemClick() | Called when the menu item is clicked. |
OnMouseEnter(MouseEventArgs) | Called before MouseEnter event occurs. |
OnMouseLeave(MouseEventArgs) | Called before the MouseLeave event occurs. |
OnMouseLeftButtonDown(MouseButtonEventArgs) | Called before the System.Windows.UIElement.MouseLeftButtonDown event occurs. |
OnMouseLeftButtonUp(MouseButtonEventArgs) | Called before the MouseLeftButtonUp event occurs. |
OnMouseMove(MouseEventArgs) | Called before the MouseMove event occurs. |
OnUnchecked() | Raises Unchecked event. |
PrepareContainerForItemOverride(DependencyObject, object) | Prepares the specified element to display the specified item. |
RefreshOffset() | Refresh offset. |
TryNavigateCore() | Called when the menu item is about to perform navigation based on specified URI. |
UpdateCanExecute() | Invalidates the CanExecute state of the command associated to this button. |
UpdateCommandUIState() | Updates the current state of the UI based on the associated Command. |
Events
Checked | Occurs when item is checked. |
Click | Occurs when item is clicked. |
Repositioned | Occurs when the popup is repositioned. |
SubMenuClosed | Occurs when the popup is closed. |
SubMenuOpened | Occurs when the popup is closed. |
Unchecked | Occurs when item is unchecked. |
Public Constructors
public UXMenuItem()
Initializes a new instance of the UXMenuItem class.
Public Properties
public Thickness BoundaryOffset { get; set; }
Gets or set the minimum boundary offset.
public double ClickLatency { get; set; }
Gets or sets the latency, in seconds, before the click action is executed.
public ICommand Command { get; set; }
Gets or sets the command to invoke when this button is clicked.
public NoExecuteBehavior CommandCannotExecute { get; set; }
Gets or sets the UI behavior when the associated Command cannot be executed.
public object CommandParameter { get; set; }
Gets or sets the parameter to pass to the Command property.
public UIElement CommandTarget { get; set; }
Gets or sets the element on which to raise the specified command.
public Grid ContentElement { get; }
Gets the content element.
public Thickness ContentMargin { get; set; }
Gets or sets the outer margin of content element.
public ContentPresenter ContentPresenter { get; }
Gets the content presenter.
public ImageSource DefaultCheckedImageSource { get; set; }
Gets or sets the checked image source.
public PopupAnimation DisplayAnimation { get; set; }
Gets or sets a value that determines the display animation.
public bool EnableFadeInAnimation { get; set; }
Gets or sets a value that determines whether the fade animation is enabled.
public bool EnableFadeOutAnimation { get; set; }
Gets or sets a value that determines whether the fade animation is enabled.
public string GroupName { get; set; }
Gets or sets the group name.
public PopupAnimation HideAnimation { get; set; }
Gets or sets a value that determines the hide animation.
public double HorizontalOffset { get; set; }
Gets or sets the distance between the left side of the Silverlight control and the left side of the popup.
public ImageSource Icon { get; set; }
Gets or sets the source for the image.
public DataTemplate IconTemplate { get; set; }
Gets or sets the template to apply to Icon element.
public double ImageHeight { get; set; }
Gets or sets the height of the image.
public Thickness ImageMargin { get; set; }
Gets or sets the margin of the image.
public Stretch ImageStretch { get; set; }
Gets or sets the image stretch mode.
public double ImageWidth { get; set; }
Gets or sets the width of the image.
public Visibility IndicatorVisibility { get; set; }
Gets or sets the visibility of indicator element.
public string InputGestureText { get; set; }
Gets or sets the input gesture text.
public bool IsCheckable { get; set; }
Gets or sets a value that determine whether the item is checkable.
public bool IsChecked { get; set; }
Gets or seta a value that determine whetehr the item is checked.
public bool IsEnabled { get; set; }
Gets or sets a value indicating whether the user can interact with the control.
public bool IsOpen { get; set; }
Gets or sets whether the popup is currently displaying on the screen.
public bool IsSelectable { get; set; }
Gets or sets a value that indicates whether the item is selectable.
public UXMenu MenuElement { get; }
Gets the menu element.
public Uri NavigateUri { get; set; }
Gets or sets the URI to navigate when this menu item is clicked.
public PopupHorizontalDirection PreferredHorizontalDirection { get; set; }
Gets or sets the preferred horizontal direction.
public PopupPosition PreferredPosition { get; set; }
Gets or sets the preferred pop up positions.
public PopupVerticalDirection PreferredVerticalDirection { get; set; }
Gets or sets the preferred vertical direction.
public Grid RootElement { get; }
Gets the root element.
public Direction SlideDirection { get; set; }
Gets or sets a value that determine the slide direction when slide animation is used.
public bool StaysOpenOnClick { get; set; }
Gets or sets a value that determines whether menu stays open when the item is clicked.
public string TargetName { get; set; }
Gets or sets the name of a target window or frame that will display the content specified by the NavigationUri property.
public double VerticalOffset { get; set; }
Gets or sets the distance between the top of the Silverlight control and the top of the popup.
Protected Properties
protected DispatcherTimer HideLatencyTimeout { get; }
Gets hide latency timeout.
protected ProductInfo Product { get; }
Product Info.
protected bool RequireUpdateCanExecute { get; set; }
Determines whether the command associated to this button require to be updated in the next call.
protected DispatcherTimer ShowLatencyTimeout { get; }
Gets show latency timeout.
Fields
public static readonly DependencyProperty BoundaryOffsetProperty
Identifies the BoundaryOffset dependency property.
public static readonly RoutedEvent CheckedEvent
Identifies the Checked routed event.
public static readonly RoutedEvent ClickEvent
Identifies the Click routed event.
public static readonly DependencyProperty ClickLatencyProperty
Identifies the BusyLatency dependency property.
public static readonly DependencyProperty CommandCannotExecuteProperty
Identifies the CommandCannotExecute dependency property.
public static readonly DependencyProperty CommandParameterProperty
Identifies the CommandParameter dependency property.
public static readonly DependencyProperty CommandProperty
Identifies the Command dependency property.
public static readonly DependencyProperty CommandTargetProperty
Identifies the CommandTarget dependency property.
public static readonly DependencyProperty ContentMarginProperty
Identifies the ContentMargin dependency property.
public static readonly DependencyProperty DefaultCheckedImageSourceProperty
Identifies the ImageSource dependency property.
public static readonly DependencyProperty DisplayAnimationProperty
Identifies the DisplayAnimation dependency property.
public static readonly DependencyProperty EnableFadeInAnimationProperty
Identifies the EnableFadeAnimation dependency property.
public static readonly DependencyProperty EnableFadeOutAnimationProperty
Identifies the EnableFadeAnimation dependency property.
public static readonly DependencyProperty GroupNameProperty
Identifies the GroupName dependency property.
public static readonly DependencyProperty HideAnimationProperty
Identifies the HideAnimation dependency property.
public static readonly DependencyProperty HorizontalOffsetProperty
Identifies the HorizontalOffset dependency property.
public static readonly DependencyProperty IconProperty
Identifies the ImageSource dependency property.
public static readonly DependencyProperty IconTemplateProperty
Identifies the IconTemplate dependency property.
public static readonly DependencyProperty ImageHeightProperty
Identifies the ImageHeight dependency property.
public static readonly DependencyProperty ImageMarginProperty
Identifies the ImageMargin dependency property.
public static readonly DependencyProperty ImageStretchProperty
Identifies the ImageStretch dependency property.
public static readonly DependencyProperty ImageWidthProperty
Identifies the ImageWidth dependency property.
public static readonly DependencyProperty IndicatorVisibilityProperty
Identifies the IndicatorVisibility dependency property.
public static readonly DependencyProperty InputGestureTextProperty
Identifies the InputGestureText dependency property.
public static readonly DependencyProperty IsCheckableProperty
Identifies the IsCheckable dependency property.
public static readonly DependencyProperty IsCheckedProperty
Identifies the IsChecked dependency property.
public static readonly DependencyProperty IsEnabledProperty
Identifies the IsEnabled dependency property.
public static readonly DependencyProperty IsOpenProperty
Identifies the IsOpen dependency property.
public static readonly DependencyProperty IsSelectableProperty
Identifies the IsSelectable dependency property.
public static readonly DependencyProperty NavigateUriProperty
Identifies the NavigationUri dependency property.
public static readonly DependencyProperty PreferredHorizontalDirectionProperty
Identifies the PreferredPosition dependency property.
public static readonly DependencyProperty PreferredPositionProperty
Identifies the PreferredPosition dependency property.
public static readonly DependencyProperty PreferredVerticalDirectionProperty
Identifies the PreferredVerticalDirection dependency property.
public static readonly DependencyProperty ShowLatencyProperty
Identifies the ShowLatency dependency property.
public static readonly DependencyProperty SlideDirectionProperty
Identifies the SlideDirection dependency property.
public static readonly DependencyProperty StaysOpenOnClickProperty
Identifies the StaysOpenOnClick dependency property.
public static readonly DependencyProperty TargetNameProperty
Identifies the TargetName dependency property.
public static readonly RoutedEvent UncheckedEvent
Identifies the Unchecked routed event.
public static readonly DependencyProperty VerticalOffsetProperty
Identifies the VerticalOffset dependency property.
Public Methods
public void AttachEventHandlers()
Attach built-in event handlers to control templates. Call this method if necessary.
public void DetachedEventHandlers()
Detach built-in event handlers from control templates. Call this method if necessary.
public void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Hide()
Hide the context menu.
public void InitializeTemplates()
Initializes control templates.
public void OnApplyTemplate()
Builds the visual tree for the UXMenuItem when a new template is applied.
public void Select()
Select the item.
public void Unselect()
Unselect the current menu item.
Protected Methods
protected void ApplyBinding(DependencyObject element, object item)
Applies item binding for each generated element.
Parameters
element | Container element. |
item | Item. |
protected void ApplyStyle(DependencyObject element, object item)
Applies style for container element generated for each item.
Parameters
element | Container element. |
item | Item. |
protected void ChangeVisualState(bool useTransitions)
Change Visual State.
Parameters
useTransitions | Use transitions. |
protected void DoToggle()
Do toggle.
protected DependencyObject GetContainerForItemOverride()
Creates or identifies the element that is used to display the given item.
Return Types
The element that is used to display the given item. |
protected void GoToCheckedState()
Go to checked state.
protected void GoToCheckedState(bool animate)
Go to checked state.
Parameters
animate | Use transitions. |
protected void GoToDisabledMouseOverState()
Go to disabled state.
protected void GoToDisabledMouseOverState(bool animate)
Go to disabled state.
Parameters
animate | Use transitions. |
protected void GoToPressedState()
Go to pressed state.
protected void GoToPressedState(bool animate)
Go to pressed state.
Parameters
animate | Use transitions. |
protected void GoToUncheckedState()
Go to unchecked state.
protected void GoToUncheckedState(bool animate)
Go to unchecked state.
Parameters
animate | Use transitions. |
protected bool IsItemItsOwnContainerOverride(object item)
Determines if the specified item is (or is eligible to be) its own container.
Parameters
item | The item to check. |
Return Types
true if the item is (or is eligible to be) its own container; otherwise, false. |
protected void OnChecked()
Raises Checked event.
protected void OnCommandChanged(ICommand oldCommand, ICommand newCommand)
Invoked when the Command dependency property is changed.
Parameters
oldCommand | The old command. |
newCommand | The new command. |
protected void OnHeaderChanged(object oldHeader, object newHeader)
Called when the value of the Header property changes.
Parameters
oldHeader | The old value of the Header property. |
newHeader | The new value of the Header property. |
protected void OnInitializeCommandDefault(ICommand command)
Invoked when the Command is initialized.
Parameters
command | The command to be initialized. |
protected void OnIsSelectedChanged(bool oldValue, bool newValue)
Parameters
oldValue | |
newValue |
protected void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Called when the value of the System.Windows.Controls.ItemsControl.Items property changes.
Parameters
e | NotifyCollectionChangedEventArgs that contains the event data |
protected void OnLostMouseCapture(MouseEventArgs e)
Called before the System.Windows.UIElement.LostMouseCapture event occurs.
Parameters
e | The data for the event. |
protected void OnMenuItemClick()
Called when the menu item is clicked.
protected void OnMouseEnter(MouseEventArgs e)
Called before MouseEnter event occurs.
Parameters
e | The data for the event. |
protected void OnMouseLeave(MouseEventArgs e)
Called before the MouseLeave event occurs.
Parameters
e | The data for the event. |
protected void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Called before the System.Windows.UIElement.MouseLeftButtonDown event occurs.
Parameters
e | The data for the event. |
protected void OnMouseLeftButtonUp(MouseButtonEventArgs e)
Called before the MouseLeftButtonUp event occurs.
Parameters
e | The data for the event. |
protected void OnMouseMove(MouseEventArgs e)
Called before the MouseMove event occurs.
Parameters
e | The data for the event. |
protected void OnUnchecked()
Raises Unchecked event.
protected void PrepareContainerForItemOverride(DependencyObject element, object item)
Prepares the specified element to display the specified item.
Parameters
element | The container element used to display the specified item. |
item | The item to display. |
protected void RefreshOffset()
Refresh offset.
protected bool TryNavigateCore()
Called when the menu item is about to perform navigation based on specified URI.
Return Types
True if the navigation succeed. |
protected void UpdateCanExecute()
Invalidates the CanExecute state of the command associated to this button.
protected void UpdateCommandUIState()
Updates the current state of the UI based on the associated Command.
Events
public event ISRoutedEventHandler Checked
Occurs when item is checked.
public event ISRoutedEventHandler Click
Occurs when item is clicked.
public event UXPopupRoutedEventHandler Repositioned
Occurs when the popup is repositioned.
public event ISRoutedEventHandler SubMenuClosed
Occurs when the popup is closed.
public event ISRoutedEventHandler SubMenuOpened
Occurs when the popup is closed.
public event ISRoutedEventHandler Unchecked
Occurs when item is unchecked.