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