XAML样式的WPF4 DataGridHeaderBorder [英] WPF4 DataGridHeaderBorder in a xaml Style

查看:137
本文介绍了XAML样式的WPF4 DataGridHeaderBorder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提出一个单独的问题,与对 WPF 4的答案的评论有关

Making a separate question, related to comments on the answer to WPF 4: What happened to DataGridColumnHeader?

似乎我可以在UserControl中使用DataGridHeaderBorder,可以在ResourceDictionary中独立使用,但不能在模板的样式设置器中使用。 / p>

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆