我想创建一个WPF右键单击ContextMenu,它只显示大图形图标。例如,一个3x3网格的64x64像素图标。这可能是通过修改ContextMenu.Template吗?
感谢。
答案 0 :(得分:1)
是的,只需修改ControlTemplate
ContextMenu
即可
<Border >
<Border.ContextMenu>
<ContextMenu>
<ContextMenu.Template>
<ControlTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="64"/>
<RowDefinition Height="64"/>
<RowDefinition Height="64"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="64"/>
<ColumnDefinition Width="64"/>
<ColumnDefinition Width="64"/>
</Grid.ColumnDefinitions>
<Image Source="icon1.png" Grid.Column="0" Grid.Row="0"/>
<Image Source="icon2.png" Grid.Column="1" Grid.Row="0"/>
<Image Source="icon3.png" Grid.Column="2" Grid.Row="0"/>
<Image Source="icon4.png" Grid.Column="0" Grid.Row="1"/>
<Image Source="icon5.png" Grid.Column="1" Grid.Row="1"/>
<Image Source="icon6.png" Grid.Column="2" Grid.Row="1"/>
<Image Source="icon7.png" Grid.Column="0" Grid.Row="2"/>
<Image Source="icon8.png" Grid.Column="1" Grid.Row="2"/>
<Image Source="icon9.png" Grid.Column="2" Grid.Row="2"/>
</Grid>
</ControlTemplate>
</ContextMenu.Template>
</ContextMenu>
</Border.ContextMenu>
</Border>