への結合:は、私は次の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>
基本的に、私はItemsControlにでItemsPresenterをテンプレートますItemsPanelTemplateとして設定されたカスタムパネル(UniformGridRtL)を、持っています。 UniformGridRtLにはバインドしたいプロパティがありますが、ElementNameはLabel Bindingで機能していないようです。 生成されたItemsControlアイテムホストのプロパティにどのようにバインドできますか?
回避策ありがとう...バインディングターゲットがテンプレートアイテムでない場合は、実際に動作します。同じItemsControl ControlTemplate内の兄弟要素にバインドする場合はどうなりますか? – Mart
送信元の使用(namedItemsControl).Template.FindName()をここで説明するように使用する代わりに、兄弟ソース要素がある場合:http://stackoverflow.com/questions/820201/how-to-access-a-wpf- control-located-in-a-controltemplate –
申し訳ありませんが、私のコメントは、ターゲットがテンプレート化されている場合、Template.FindName()と同じ戦略を使用することができます - コードはちょっと混乱します。まだ何らかの種類のLoadedイベントを使用するようにしてください。そうしないと、ビジュアルツリーはまだ作成されず、FindNameはnullを返します。 –