问题描述
提出一个单独的问题,与对 WPF 4:发生了什么的答案的评论有关到 DataGridColumnHeader?
Making a separate question, related to comments on the answer to WPF 4: What happened to DataGridColumnHeader?
看来我可以在 UserControl 中使用 DataGridHeaderBorder,在 ResourceDictionary 中独立使用,但不能在模板的样式设置器中使用.
It appears I can use DataGridHeaderBorder in a UserControl, stand-alone in a ResourceDictionary, but not in a Style's setter of a Template.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<!-- Works -->
<DataTemplate x:Key="yomama">
<DataGridColumnHeader />
</DataTemplate>
<!-- Compile Error: error MC3074: The tag 'DataGridHeaderBorder' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. -->
<Style x:Key="{x:Type DataGridRowHeader}"
TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRowHeader}">
<Grid>
<DataGridHeaderBorder></DataGridHeaderBorder>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
如果我使用 xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit",即使我没有在项目中引用 WPFToolkit,我也可以让它工作.我已确认我已设置为 .NET4 并参考 PresentationFramework v4.
I can get it to work if I use xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit", even though I'm not referencing WPFToolkit in the project. I've verified I'm set to .NET4 and referencing PresentationFramework v4.
感谢您帮我删除 dg: hack.
Thanks for helping me remove the dg: hack.
推荐答案
尝试:
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
这篇关于xaml 样式中的 WPF4 DataGridHeaderBorder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!