我正在开发一个从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属性绑定到.BorderDataTemplateMyItemsControl
如果在这里发现几个问题,建议MyItemsControl在绑定中使用元素名称,但这仅在定义ItemTemplate使用控件的位置时才有效。我还尝试绑定到RelativeSource定义local:MyItemsControl为祖先类型。
没有任何效果。我在这里想念什么?