I need some help translating the following .XAML code below to its corresponding C# code:
<ContextMenu x:Name="MenuImageContextMenu" Background="White" Width="175" Height="100">
<ContextMenu.Template>
<ControlTemplate>
<Grid x:Name="ContextMenuGrid" Background="{TemplateBinding Background}">
<Grid x:Name="BeverageGrid" Background="{TemplateBinding Background}" Height="50">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="3.5*" />
<ColumnDefinition Width="6*" />
</Grid.ColumnDefinitions>
<Image x:Name="BeverageImage" Grid.Column="1" Grid.RowSpan="3" Source="/DinerPOS;component/Resources/Images/Restaurant/Beverages/Beverage.png" Stretch="Fill" />
<TextBlock x:Name="BeverageLabel" Grid.Column="2" Grid.RowSpan="3" Text="Beverages" HorizontalAlignment="Center" TextAlignment="Center" VerticalAlignment="Center" />
</Grid>
</Grid>
</ControlTemplate>
</ContextMenu.Template>
</ContextMenu>
What I have tried so far
ContextMenu ContextMenu = new ContextMenu();
ControlTemplate ControlTemplate = new ControlTemplate();
// ControlTemplate.VisualTree = Grid ????
ContextMenu.Name = MenuImageContextMenu;
ContextMenu.Template = ControlTemplate;
But I don't know how to add the main Grid ContextMenuGrid
to the ControlTemplate
.