我正在开发一个从ItemsControl
. 在 generic.xaml 文件中,我为该控件创建了样式并定义了一个ItemTemplate
:
<Style TargetType="local:MyItemsControl">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="Red">
<!-- Other things in here -->
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
我想将in 的Background
属性绑定到.Border
DataTemplate
MyItemsControl
如果在这里发现几个问题,建议MyItemsControl
在绑定中使用元素名称,但这仅在定义ItemTemplate
使用控件的位置时才有效。我还尝试绑定到RelativeSource
定义local:MyItemsControl
为祖先类型。
没有任何效果。我在这里想念什么?