Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Gets or sets a value indicating whether the menu item is checked.
Namespace:  Microsoft.Windows.Design.Interaction
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)
Syntax
'Declaration
Public Property Checked As Boolean
'Usage
Dim instance As MenuAction 
Dim value As Boolean 
value = instance.Checked
instance.Checked = value
public bool Checked { get; set; }
public:
property bool Checked {
    bool get ();
    void set (bool value);
}
public function get Checked () : boolean 
public function set Checked (value : boolean)
Property Value
Type: System.Boolean
true if the menu item should be rendered with a check mark; otherwise, false. The default is false.
Remarks
The Checked property has an effect only if property Checkable is set to true.
Examples
The following code example shows how to set up two MenuAction items according to the value of a control's Background property. For more information, see Walkthrough: Creating a MenuAction.
' The following method handles the UpdateItemStatus event. 
' It sets the MenuAction states according to the state 
' of the control's Background property. This method is 
' called before the context menu is shown. 
Sub CustomContextMenuProvider_UpdateItemStatus( _
    ByVal sender As Object, _
    ByVal e As MenuActionEventArgs)
    ' Turn everything on, and then based on the value  
    ' of the BackgroundProperty, selectively turn some off.
    clearBackgroundMenuAction.Checked = False
    clearBackgroundMenuAction.Enabled = True
    setBackgroundToBlueMenuAction.Checked = False
    setBackgroundToBlueMenuAction.Enabled = True 
    ' Get a ModelItem which represents the selected control.  
    Dim selectedControl As ModelItem = _
        e.Selection.PrimarySelection
    ' Get the value of the Background property from the ModelItem. 
    Dim backgroundProperty As ModelProperty = _
        selectedControl.Properties(Control.BackgroundProperty)
    ' Set the MenuAction items appropriately. 
    If Not backgroundProperty.IsSet Then
        clearBackgroundMenuAction.Checked = True
        clearBackgroundMenuAction.Enabled = False 
    ElseIf backgroundProperty.ComputedValue.Equals(Brushes.Blue) Then
        setBackgroundToBlueMenuAction.Checked = True
        setBackgroundToBlueMenuAction.Enabled = False 
    End If 
End Sub
// The following method handles the UpdateItemStatus event. 
// It sets the MenuAction states according to the state 
// of the control's Background property. This method is 
// called before the context menu is shown. 
void CustomContextMenuProvider_UpdateItemStatus(
    object sender, 
    MenuActionEventArgs e)
{
    // Turn everything on, and then based on the value  
    // of the BackgroundProperty, selectively turn some off.
    clearBackgroundMenuAction.Checked = false;
    clearBackgroundMenuAction.Enabled = true;
    setBackgroundToBlueMenuAction.Checked = false;
    setBackgroundToBlueMenuAction.Enabled = true;
    // Get a ModelItem which represents the selected control. 
    ModelItem selectedControl = e.Selection.PrimarySelection;
    // Get the value of the Background property from the ModelItem.
    ModelProperty backgroundProperty = 
        selectedControl.Properties[Control.BackgroundProperty];
    // Set the MenuAction items appropriately. 
    if (!backgroundProperty.IsSet)
    {
        clearBackgroundMenuAction.Checked = true;
        clearBackgroundMenuAction.Enabled = false;
    }
    else if (backgroundProperty.ComputedValue == Brushes.Blue)
    {
        setBackgroundToBlueMenuAction.Checked = true;
        setBackgroundToBlueMenuAction.Enabled = false;
    }
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.Windows.Design.Interaction Namespace
PrimarySelectionContextMenuProvider