Articles in this section
Category / Section

How to set context menu for TileViewItems in TileView Control

1 min read

This article describes how to set context menu for all the items in TileViewControl.

ContextMenu

Create and add menu items to the ContextMenu. Using ItemContainerStyle property of TileViewControl, set the context menu for all TileViewItems.

The following code example demonstrates the same.

XAML               

<Window x:Class="TileViewControl_ContextMenu.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    
mc:Ignorable="d" xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
        Title="TileViewControl ContextMenu" Height="350" Width="525">
    <Grid>
        <syncfusion:TileViewControl>
            <syncfusion:TileViewControl.ItemContainerStyle>
                <Style TargetType="syncfusion:TileViewItem">
                    <Setter Property="ContextMenu">
                        <Setter.Value>
                            <ContextMenu>
                                <MenuItem Header="MenuItem">
                                    <MenuItem.Style>
                                        <Style TargetType="MenuItem">
                                            <EventSetter Event="MenuItem.Click" Handler="MenuItem_Click"/>
                                        </Style>
                                    </MenuItem.Style>
                                </MenuItem>
                            </ContextMenu>
                        </Setter.Value>
                    </Setter>
                </Style>
            </syncfusion:TileViewControl.ItemContainerStyle>
            <syncfusion:TileViewItem Header="TileViewItem 1"                                         
               Content="TileViewContent" />
            <syncfusion:TileViewItem Header="TileViewItem 2"                                          
               Content="TileViewContent"/>
            <syncfusion:TileViewItem Header="TileViewItem 3" 
               Content="TileViewContent" />
            <syncfusion:TileViewItem Header="TileViewItem 4" 
               Content="TileViewContent" />
            <syncfusion:TileViewItem Header="TileViewItem 5" 
               Content="TileViewContent" />
            <syncfusion:TileViewItem Header="TileViewItem 6" 
               Content="TileViewContent" />            
        </syncfusion:TileViewControl>
    </Grid>
</Window>

C#

  private void MenuItem_Click(object sender, RoutedEventArgs e)
        {         
         MessageBox.Show("MenuItem clicked");
        }

 

The following screenshots illustrates the output of the above code example

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment