Context Menu Visual is null
Posted: 08 Feb 2022, 22:53
Hello,
I am currently looking to add a context menu to assist in debugging. When I follow the context menu example provided the MenuItems do not seem to format correctly and a Noesis Error is throw; `Visual is null`. Am I missing something?
I am currently looking to add a context menu to assist in debugging. When I follow the context menu example provided the MenuItems do not seem to format correctly and a Noesis Error is throw; `Visual is null`. Am I missing something?
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Border Width="360" Background="Gray" Padding="20">
<Border.ContextMenu>
<ContextMenu>
<MenuItem Header="View">
<MenuItem Header="Large icons"/>
<MenuItem Header="Small icons"/>
<MenuItem Header="List"/>
<MenuItem Header="Details"/>
</MenuItem>
<MenuItem Header="Sort by">
<MenuItem Header="Name"/>
<MenuItem Header="Date"/>
<MenuItem Header="Type"/>
</MenuItem>
<MenuItem Header="Refresh"/>
<Separator/>
<MenuItem Header="Pin to TaskBar" IsCheckable="True"/>
</ContextMenu>
</Border.ContextMenu>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False" Text="Right click to open Context Menu"/>
</Border>
</Grid>
</Grid>