【发布时间】:2020-06-02 07:00:41
【问题描述】:
我将拆分按钮定义如下(在控件模板中)。当用户选择一个菜单项时,我希望菜单关闭。我不知道它是否在未关闭的 SplitButton 或 Menu 中。它也尝试使用 ListBox,而不是菜单并得到相同的结果。
IsSplitButtonOpen 和所有其他绑定属性都在视图模型中定义。 IsSplitButtonOpen 在命令的事件处理程序中设置为 false。
<telerik:RadSplitButton Content="New Search"
Height="22"
Visibility="{TemplateBinding AddButtonVisibility}"
AutoOpenDelay="0:0:0.5"
IsOpen="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadTabbedWindow}}, Path=DataContext.IsSplitButtonOpen}"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadTabbedWindow}}, Path=DataContext.ShowSearchCommand}"
CommandParameter="SearchAccountsView">
<telerik:RadSplitButton.DropDownContent>
<telerik:RadMenu Orientation="Vertical"
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadTabbedWindow}}, Path=DataContext.NewTabListItems}" >
<telerik:RadMenu.ItemTemplate>
<DataTemplate>
<telerik:RadMenuItem Header="{Binding Text}"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadTabbedWindow}}, Path=DataContext.ShowSearchCommand}"
CommandParameter="{Binding ViewName}"
/>
</DataTemplate>
</telerik:RadMenu.ItemTemplate>
</telerik:RadMenu>
</telerik:RadSplitButton.DropDownContent>
</telerik:RadSplitButton>
【问题讨论】: