为 WPF 数据网格标题添加下划线

发布于 2024-07-16 17:43:18 字数 46 浏览 4 评论 0原文

我有一个很愚蠢的问题要问你..:P 如何在 DataGrid 标题下划线?

I have very silly question to ask you.. :P
how can I underline the DataGrid headers ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Saygoodbye 2024-07-23 17:43:18
 <Window 
x:Class="Test.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
xmlns:dgp="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit"
Title="Window1" Height="300" Width="300">
<Window.Resources>
    <Style TargetType="dgp:DataGridColumnHeader">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dgp:DataGridColumnHeader">
                    <Label>
                        <Underline>
                            <ContentPresenter/>
                        </Underline>
                    </Label>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid>
    <dg:DataGrid>
        <dg:DataGrid.Columns>
            <dg:DataGridTextColumn Header="No." Width="50">
            </dg:DataGridTextColumn>
        </dg:DataGrid.Columns>
    </dg:DataGrid>
</Grid>
</Window>
 <Window 
x:Class="Test.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
xmlns:dgp="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit"
Title="Window1" Height="300" Width="300">
<Window.Resources>
    <Style TargetType="dgp:DataGridColumnHeader">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dgp:DataGridColumnHeader">
                    <Label>
                        <Underline>
                            <ContentPresenter/>
                        </Underline>
                    </Label>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid>
    <dg:DataGrid>
        <dg:DataGrid.Columns>
            <dg:DataGridTextColumn Header="No." Width="50">
            </dg:DataGridTextColumn>
        </dg:DataGrid.Columns>
    </dg:DataGrid>
</Grid>
</Window>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文