[問題] wpf Expander 當 item 被選取自動 expand
我做了一個 ListView 跟 DataGridView
都完成了 Grouping 的動作
但是當我動態去改變 selectd 的時候(也靜態給定初始值)
group 的 expander 沒辦法自動地展開
部分的 xaml design 如下:
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander IsExpanded="{Binding
Mode=TwoWay, Path=IsSelected, RelativeSource={RelativeSource
AncestorType=ListViewItem, Mode=FindAncestor}}">
<Expander.Header>
<StackPanel
Orientation="Horizontal">
<TextBlock Text="{Binding
Name}" FontWeight="Bold" Foreground="Gray" FontSize="16"
VerticalAlignment="Bottom"/>
<TextBlock Text="{Binding
ItemCount}" FontSize="22" Foreground="Green" FontWeight="Bold"
FontStyle="Italic" Margin="10,0,0,0" VerticalAlignment="Bottom" />
<TextBlock Text="
item(s)" FontSize="22" Foreground="Silver" FontStyle="Italic"
VerticalAlignment="Bottom" />
</StackPanel>
</Expander.Header>
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
主要的應該就是
<Expander IsExpanded="{Binding Mode=TwoWay, Path=IsSelected,
RelativeSource={RelativeSource AncestorType=ListViewItem,
Mode=FindAncestor}}">
將 AncestorType 設為 ListViewItem 是否正確??
還是上面還缺了甚麼宣告?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.128.199.139
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1490337699.A.B18.html
※ 編輯: b26168 (220.128.199.139), 03/24/2017 14:59:32
推
03/29 00:55, , 1F
03/29 00:55, 1F
→
03/29 00:56, , 2F
03/29 00:56, 2F
→
03/29 00:57, , 3F
03/29 00:57, 3F
→
03/29 00:58, , 4F
03/29 00:58, 4F
→
03/29 00:59, , 5F
03/29 00:59, 5F
→
03/29 01:00, , 6F
03/29 01:00, 6F
→
03/29 01:01, , 7F
03/29 01:01, 7F
→
03/29 01:02, , 8F
03/29 01:02, 8F
→
03/29 01:03, , 9F
03/29 01:03, 9F
→
03/29 01:04, , 10F
03/29 01:04, 10F
→
03/29 01:04, , 11F
03/29 01:04, 11F
→
03/29 01:06, , 12F
03/29 01:06, 12F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章
11
21
11
17