简体   繁体   English

使用GroupStyle过滤ComboBox

[英]Filtering a ComboBox with a GroupStyle

I have a Telerik ComboBox which has a GroupStyle applied to it. 我有一个Telerik ComboBox,它有一个GroupStyle。 I want to have it so that when the items are filtered, the group items disappear if they have no children items, and it continues up the hierarchy. 我想拥有它,以便在过滤项目时,如果组项目没有子项目,则组项目将消失,并且它继续向上层次结构。

So, this is the initial setup: 所以,这是初始设置:

在此输入图像描述

Current: 当前:

在此输入图像描述

Desired: 期望:

在此输入图像描述

For reference: 以供参考:

GroupItem Style GroupItem风格

<Style TargetType="{x:Type GroupItem}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Expander Header="{Binding Path=Name}">
                    <ItemsPresenter Margin="20,0,0,0" />
                </Expander>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Style.Triggers>
        <DataTrigger
            Binding="{Binding Path=Name}"
            Value="{x:Null}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <ItemsPresenter />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </DataTrigger>
    </Style.Triggers>
</Style>

RadComboBox radcombobox控件

<telerik:RadComboBox
    Grid.Column="1"
    DisplayMemberPath="Name"
    IsEditable="True"
    IsFilteringEnabled="True"
    ItemsSource="{Binding Path=Analyzers}"
    KeyboardNavigation.TabNavigation="Local"
    OpenDropDownOnFocus="True"
    SelectedItem="{Binding Path=Analyzer, Mode=OneWayToSource}"
    SelectedValue="{Binding Path=AnalyzerId, Converter={utilities:NullToZeroValueConverter}}"
    SelectedValuePath="Id"
    Style="{StaticResource ResourceKey=RadComboBoxStyle.CanDisable}"
    TabIndex="2">
    <telerik:RadComboBox.ItemContainerStyle>
        <Style
            BasedOn="{StaticResource ResourceKey=RadComboBoxItemStyle}"
            TargetType="telerik:RadComboBoxItem">
            <Setter Property="ToolTip" Value="{Binding Path=Description}" />
        </Style>
    </telerik:RadComboBox.ItemContainerStyle>
    <telerik:RadComboBox.GroupStyle>
        <GroupStyle />
    </telerik:RadComboBox.GroupStyle>
</telerik:RadComboBox>       

I found the following (related) example on the Telerik forums. 我在Telerik论坛上找到了以下(相关)示例。 Example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM