2
我有一个SplitButton
在我的WPF窗口,这是从Xceed的扩展WPF工具包借来的。其下拉内容由一些RadioButton
组成。喜欢的东西:WPF-如何隐藏下拉菜单后点击
<Window x:Class="WpfTest.Test3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tk="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
Title="Test3" Height="300" Width="300">
<Grid Height="25" Width="150">
<tk:SplitButton Content="Default Command">
<tk:SplitButton.DropDownContent>
<StackPanel>
<RadioButton Content="Default Command" GroupName="variations" Margin="5" IsChecked="True"/>
<RadioButton Content="Alternate Command 1" GroupName="variations" Margin="5"/>
<RadioButton Content="Alternate Command 2" GroupName="variations" Margin="5"/>
</StackPanel>
</tk:SplitButton.DropDownContent>
</tk:SplitButton>
</Grid>
</Window>
产生这样的:
的问题是,当我点击每个RadioButton
S中的下拉菜单不dissappear的。我做了一些Google搜索,意识到我应该为每个RadioButton
处理Click
事件。但我不知道如何隐藏该事件处理程序中的下拉菜单。作为一个侧面说明,它似乎是一个MenuItem
has the property ofStaysOpenOnClick
,但没有其他控件的这种事情。
尽管以编程方式完成此操作就足够了,但有没有MVVM的方式?
不完全是你的问题的解决方案,但你为什么宁可单选按钮在下拉列表? –
@确定什么是下拉列表? 'SplitButton'有一个'DropDownContent'属性,可以用'MenuItem'或者我尝试的那个来填充。我没有明白你的意思 –
对不起,我的意思是一个组合框:https://www.dotnetperls.com/combobox-wpf –