问题描述
<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style targettype="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander IsExpanded="True">
<Expander.Header>
<TextBlock Margin="10 5 0 0">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}: {1}">
<Binding Path="Name" />
<Binding Path="ItemCount" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Expander.Header>
<Expander.Content>
<ItemsPresenter />
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListBox.GroupStyle>
这工作正常。
现在,如果组中有 10 个或更多项目,我想折叠扩展器(仅在计数更改后,保留用户手动展开和折叠的可能性)。我怎样才能做到这一点?
我写了一个 IsLessthanConverter : IValueConverter
,它接受一个参数,如果传递的值小于参数,则返回 true。
但是,我不知道如何在此处集成此转换器。我尝试过这样的事情,但从未调用转换器:
<Expander IsExpanded="{Binding Path=Count,RelativeSource={RelativeSource Self},Converter={StaticResource IsLessthanConverter},ConverterParameter=10,Mode=OneWay}">
...
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)