0
我有以下XAML:綁定到ItemsPresenter屬性
<ItemsControl ItemsSource="{Binding...}" >
<ItemsControl.Template>
<ControlTemplate>
<ItemsPresenter x:Name="testGrid"/>
</ControlTemplate>
</ItemsControl.Template>
<!--Use the ItemsPanel property to specify a custom UniformGrid that
holds the laid out items.-->
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<tools:UniformGridRtL Columns="8" x:Name="testGrid2" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<!--Use the ItemTemplate to set a DataTemplate to define
the visualization of the data objects. This DataTemplate
specifies that each data object appears RegisterBit appears
as a CheckBox bound to RegisterBit properties. It also defines
a custom template for the checkbox.-->
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox... />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Label>
<Binding ElementName="testGrid2" Path="property_of_UniformGridRtL"/>
</Label>
基本上,我有設定爲ItemsPanelTemplate定製面板(UniformGridRtL),這將在ItemsControl的模板的ItemsPresenter。 UniformGridRtL有一個我想綁定的屬性,但ElementName在標籤綁定中似乎不起作用。 如何綁定到生成的ItemsControl項目主機的屬性?
感謝您的解決方法......如果綁定目標不是模板項目,它確實有效。如果我想綁定到同一個ItemsControl ControlTemplate中的同級元素,會發生什麼? – Mart 2011-01-07 17:31:46