首页 > 解决方案 > 绑定到另一个控件行为

问题描述

我创建了一个混合行为来设置数据网格的列。

<DataGrid ItemsSource="{Binding Source}">
        <i:Interaction.Behaviors>
            <behaviors:DataGridBehavior ColumnsSource="{Binding SourceHeaders}"/>
        </i:Interaction.Behaviors>
</DataGrid>

我现在想要做的是在另一个控件中使用 ColumnsSource (目前正在样式的 Template 属性中捕获)。像这样的东西:

<ItemsControl ItemsSource={{Binding ???, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}} />

由于缺乏搜索结果,我不确定这是否可能。我正在开始研究附加属性,但我想做的可能吗?

标签: wpfxamlbehavior

解决方案


推荐阅读