我DataGridTemplateColumn在我的 XAML 中使用了几个 s DataGrid,每个都是一组文本框,因为我想要列的分组标题布局(例如,合并列作为 excel 中的标题)。
所有这一切都很好,因为我正在使用HeaderStyle列的属性来加载一个定义布局并实现分组标题的StaticResourcefor 。StyleGrid
问题是,需要将Header属性DataGridTemplateColumn绑定到模型成员(或 StaticResource ?),因为它将包含将在 a 中使用的字符串值ContentPresenter,它是HeaderStyle. ContentPresenter资源中的Style定义如下:
<ContentPresenter Grid.Row="2" Content="{TemplateBinding Content}"
VerticalAlignment="Center" HorizontalAlignment="Center"
Grid.ColumnSpan="11">
但这不起作用。它仅适用Header="SomeString于 ,但只要我将其更改为
Header="{Binding Something}"或Header="{StaticResource SomeResource}"它只显示一个空白标题。
我在这里错过了什么吗?