我对WPF完全陌生,我试图让现有按钮显示带有菜单项的下拉列表。
最好的方法是什么?
<Button Name="ModelReport" Template="{StaticResource GlassButton}"
VerticalAlignment="Bottom" MouseEnter="ModelReport_MouseEnter" Click="CommandButton_Click">
<StackPanel Background="Transparent" Orientation="Horizontal" Margin="5,4,5,4">
<Image Width="16" Height="16" x:Name="ModelReportImage" Source="{StaticResource MyImgScrollInformation}" />
<TextBlock VerticalAlignment="Center" Margin="3,0">Model Report</TextBlock>
</StackPanel>
</Button>
答案 0 :(得分:2)
向WPF中的按钮添加上下文菜单非常容易:
<Button Content="1234">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="abcd" />
</ContextMenu>
</Button.ContextMenu>
</Button>
然而,这是令人困惑和糟糕的用户体验!
除非用户准确地知道此特定按钮上有上下文菜单,否则在用户界面中根本不可见。
更好的方法:
拆分按钮。