我有一個容器類型控件,其中包含多個項目。容器控件的DataTemplate
已定義,其中還包含ItemsControl
,該項目的DataTemplate
。但是,這些項目需要綁定到容器控件的某些內容。一個簡單的例子如下:如何從ItemsControl.ItemTemplate中綁定到父DataTemplate
<DataTemplate DataType="{x:Type ContainerType}">
<!-- Display of the container stuff-->
<ItemsControl ItemsSource="{Binding Items, Mode=OneWay}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type Item}">
<!-- Display of the item stuff -->
<ComboBox Text="Choose a container-level option..."
ItemsSource="{WHAT GOES HERE?}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
如何在項目級別綁定一些東西到容器級別?
TemplateBinding僅適用於CONTROLTEMPLATES,據我所知。 –