2
我試圖使用Expander
與一次打開時間爲。我從MSDN Forum Link得到了一個代碼。WPF嵌套擴展器綁定到ListBoxItem不起作用
<ListBox>
<!-- all styles and templates-->
<Expander Header="One"><!-- some content --></Expander>
<Expander Header="Two"><!-- some other content --></Expander>
</ListBox>
這是工作的罰款。 上述擴展器中只有一個將在時間開放。
但是,如果我嘗試一個嵌套的擴展器,較低的擴展器不按要求打開和關閉作爲上述代碼。這意味着如果我添加內容擴展「兩個」像下面
<Expander Header="Two">
<ListBox>
<!-- same styles and templates as above-->
<Expander Header="Sub-One"><!-- some content --></Expander>
<Expander Header="Sub-Two"><!-- some other content --></Expander>
</ListBox>
</Expander>
擴展器「亞一」和「分二」是一些如何鏈接到同一ListBoxItem
到擴展「二」是附
我想我需要做出一些變化的結合,但不能這樣做。
<Style TargetType="{x:Type Expander}">
<Setter Property="IsExpanded"
Value="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/>
</Style>
任何指導都會有很大的幫助。
注: - 很少有東西,我試過
-
- 在代碼中擴展的經過家長,只有列表框快到了,有一個在層次結構沒有ListBoxItem的
- 嘗試添加不同的值AncestorLevel,無除1值工作
- 正想着,綁定到列表框的SelectedIndex的,這也是我不能讓它工作作爲無法想轉換的SelectedIndex到IsExpandable的,即使我使用轉換器