ExtZGholson
Topic Author
Posts: 22
Joined: 12 Mar 2021, 01:24

Context Menu Visual is null

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?
contextmenu.png
contextmenu.png (7.73 KiB) Viewed 1202 times
contextmenuerror.png
contextmenuerror.png (6.34 KiB) Viewed 1202 times
<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>
 
ExtZGholson
Topic Author
Posts: 22
Joined: 12 Mar 2021, 01:24

Re: Context Menu Visual is null

08 Feb 2022, 23:34

I did some digging and found my answer! We need to make a visual template for the context menu.
 
User avatar
sfernandez
Site Admin
Posts: 3364
Joined: 22 Dec 2011, 19:20

Re: Context Menu Visual is null

09 Feb 2022, 12:04

Every control needs a template to render, so every time you see some control showing with a magenta background it would indicate it is using our internal debug templates.

We recommend to start by including our Theme in your application resources as base, then create the styles/template for the controls you are going to use.

Who is online

Users browsing this forum: Bing [Bot] and 3 guests