I need help binding to custom control specified in DataTemplate which is part of a custom control based on ItemsControl. The xaml for the custom control looks like:
<Style x:Key="{x:Type local:MyItemPanel}" TargetType="{x:Type local:MyItemPanel}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ItemsControl}" >
<ItemsControl x:Name="PART_itmCtrl" ItemsSource="{TemplateBinding ItemsSource}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel x:Name="PART_wrapPanel" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate >
<local:MyInnerCustomTextBoxControl Text="{Binding Path=TokenValue}" WaterMark="{Binding Path=Token}"
BorderBrush="{TemplateBinding local:MyItemPanel.WMBorderBrush}"
HorizontalAlignment="Left" BorderThickness="1" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type local:MyItemPanel}" TargetType="{x:Type local:MyItemPanel}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ItemsControl}" ><ItemsControl x:Name="PART_itmCtrl" ItemsSource="{TemplateBinding ItemsSource}"><ItemsControl.ItemsPanel><ItemsPanelTemplate><WrapPanel x:Name="PART_wrapPanel" /></ItemsPanelTemplate></ItemsControl.ItemsPanel><ItemsControl.ItemTemplate><DataTemplate ><local:MyInnerCustomTextBoxControl Text="{Binding Path=TokenValue}" WaterMark="{Binding Path=Token}" BorderBrush="{TemplateBinding local:MyItemPanel.WMBorderBrush}" HorizontalAlignment="Left" BorderThickness="1" /></DataTemplate></ItemsControl.ItemTemplate></ItemsControl></ControlTemplate></Setter.Value></Setter></Style>
The custom control is used in xaml as follow:
<y:MyItemPanel x:Name="TokenIP" WMBorderBrush="Crimson" />
Where WMBorderBrush is a Dependency Property of MyItemPanel.
I am trying to pass it into the DataTemplate. The problem is that the DataTemplate binds to the the collection defined in the View Model, which works above in the Text="{Binding Path=TokeValue}" but doesn't appear to work in the BorderBrush="{TemplateBinding local:MyItemPanel.WMBorderBrush}", so I'm thinking that my xaml syntax is not correct.
I'm looking for the proper syntax that binds BorderBrush to the WMBorderBrush dependency property of MyItemPanel.
Thanks
Robotuner