The first step: Define right-click menu in the Window.Resources
<Window.Resources> <ContextMenu x:Key="ContextMenu"> <MenuItem Name="NewFile" Header="新建文件夹"/> <Separator></Separator> <MenuItem Name="Refresh" Header="刷新"/> </ContextMenu> </Window.Resources>
Step two: Define right-click menu of events
<Window.Resources> <ContextMenu x:Key="ContextMenu"> <MenuItem Name="NewFile" Click="NewFile_Click" Header="新建文件夹"/> <Separator></Separator> <MenuItem Name="Refresh" Click="Refresh_Click" Header="刷新"/> </ContextMenu> </Window.Resources>
Third step: in which the definition of the right place, added to the need to use this property right-click menu: ContextMenu = "{StaticResource ContextMenu}"
<dxdo:LayoutPanel ShowCaption="False" ContextMenu="{StaticResource ContextMenu}"> <dx:ContentContainer x:Name="myContainer" Grid.Row="1"/> </dxdo:LayoutPanel>