提出一个单独的问题,与对WPF 4: What happened to DataGridColumnHeader?答案的评论相关
似乎我可以在UserControl中使用DataGridHeaderBorder,在ResourceDictionary中独立使用,但不能在模板的样式设置器中使用。
<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。
谢谢你帮我删除dg: hack。
发布于 2011-01-24 11:56:20
尝试:
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"发布于 2011-12-15 06:45:03
你也可以尝试this.In这种情况来改变标题的前景。
<Style x:Key="Consulta_Grilla_HeaderStyle"
TargetType="{x:Type DataGridColumnHeader}">
<Style.Resources>
<Style TargetType="{x:Type Grid}" >
<Setter Property="TextBlock.Foreground" Value="Yellow"/>
</Style>
</Style.Resources>
</Style>发布于 2015-09-16 17:00:17
在项目的引用中添加PresentationFramework.Aero.dll。
https://stackoverflow.com/questions/3365350
复制相似问题