【问题标题】:WPF: Listbox or menu will not close on click (inside a Telerik Splitbutton)WPF:单击时不会关闭列表框或菜单(在 Telerik Splitbutton 内)
【发布时间】: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>

【问题讨论】:

    标签: wpf telerik


    【解决方案1】:

    请尝试使用 CloseOnPopupMouseLeftButtonUp 属性并将其设置为 True。 RadSplitButton 和 RadDropDownButton 都具有该属性。如果 IsOpen 属性只有一个目的,你甚至可以拒绝它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 1970-01-01
      • 2018-03-14
      • 2017-07-01
      相关资源
      最近更新 更多