开发者

Setting ListView.GroupStyle in XAML dynamically?

开发者 https://www.devze.com 2023-04-12 07:07 出处:网络
I\'ve got a 开发者_如何转开发ListView, whose View is switched dynamically in runtime between an Icon mode and a Grid mode (the latter implemented with a GridView).

I've got a 开发者_如何转开发ListView, whose View is switched dynamically in runtime between an Icon mode and a Grid mode (the latter implemented with a GridView). The problem is, as I described here, that when I add ListView.GroupStyle in my ListView definition, the Icon mode gets screwed. Hence, I'd like to reset/disable GroupStyle for that mode.

So, my question: is there a way to apply/reset the GroupStyle dynamically (via a Trigger?) when I switch the ListView into the Grid mode?

I tried to do that (e.g. <Setter Property="ListView.GroupStyle" Value="{x:Null}"/>) for the Icon View, but this doesn't compile because "The Property Setter 'GroupStyle' cannot be set because it does not have an accessible set accessor."

Any suggestions will be cordially welcome :-)


There could be two ways to do this...

  1. Instead of setting the GroupStyle to x:Null keep the existing set GroupStyle as it is, but reset its inner template using DataTriggers that use TemplateBinding.

  2. Use bottom up approach, remove your GroupDescriptions from your CollectionView based on the mode.

0

精彩评论

暂无评论...
验证码 换一张
取 消