-->

Wednesday, December 16, 2015

Example of Context menu in WPF

Example of Context menu in WPF

Context Menu Introduction:
Context menu means a window appear when we click on right button of mouse on selected Text. Today, we will design context menu with the help of WPF. Here, we will take a Input control with context menu also context menu contain MenuItem.



XAML Code
<Grid>
        <RichTextBox >
            <RichTextBox.ContextMenu>
                <ContextMenu>
                    <MenuItem Command="Cut">
                        <MenuItem.Icon>
                            <Image Source="apple.png"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Command="Copy">
                        <MenuItem.Icon>
                            <Image Source="grapes.png"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>              
               
            </RichTextBox.ContextMenu>
                 
           
        </RichTextBox>

    </Grid>
Suppose, your richTextBox is disabled and you want to show context menu on disabled item then use this code:

<RichTextBox IsEnabled="False" ContextMenuService.ShowOnDisabled="True">

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved