SplitButton 分割按钮

在普通按钮的基础上提供额外的点击项.

1
public class SplitButton : ButtonBase

属性

属性 描述 默认值 备注
HitMode 下拉框触发模式 HitMode.Click
MaxDropDownHeight 下拉框最大高度
IsDropDownOpen 下拉框是否打开 false
DropDownContent 下拉框内容

案例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<StackPanel Margin="32" VerticalAlignment="Center">
<hc:SplitButton Margin="0,0,0,10" Content="{ex:Lang Key={x:Static langs:LangKeys.Default}}" Command="{Binding SelectCmd}" CommandParameter="Command0" HorizontalAlignment="Stretch">
<hc:SplitButton.DropDownContent>
<StackPanel>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command1"/>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command2"/>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command3"/>
</StackPanel>
</hc:SplitButton.DropDownContent>
</hc:SplitButton>
<hc:SplitButton Style="{StaticResource SplitButtonPrimary}" Margin="0,0,0,10" Content="{ex:Lang Key={x:Static langs:LangKeys.Primary}}" Command="{Binding SelectCmd}" CommandParameter="Command0" HorizontalAlignment="Stretch">
<hc:SplitButton.DropDownContent>
<StackPanel>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command1"/>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command2"/>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command3"/>
</StackPanel>
</hc:SplitButton.DropDownContent>
</hc:SplitButton>
<hc:SplitButton Style="{StaticResource SplitButtonWarning}" Margin="0,0,0,10" Content="{ex:Lang Key={x:Static langs:LangKeys.Warning}}" HitMode="Hover" HorizontalAlignment="Stretch">
<hc:SplitButton.DropDownContent>
<StackPanel>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command1"/>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command2"/>
<MenuItem Header="{ex:Lang Key={x:Static langs:LangKeys.Title}}" Command="{Binding SelectCmd}" CommandParameter="Command3"/>
</StackPanel>
</hc:SplitButton.DropDownContent>
</hc:SplitButton>
</StackPanel>

SplitButton