Datagrid的边框样式 [英] Border Styling for Datagrid

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

问题描述

大家好,您又得到了一个q.这是我的应用程序中的主题:

Hi guys got another q for you. This is a theme in my app:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="{x:Type Border}">
        <Setter Property="CornerRadius" Value="5"/>
        <Setter Property="Background" Value="{StaticResource TheBlue}"/>
        <Setter Property="BorderBrush" Value="Black"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="Padding" Value="2"/>
    </Style>
</ResourceDictionary>


它适用于我的应用中带有边框的任何控件.但是,我不希望这个主题适用于我的数据网格.如何防止此方法应用于我的数据网格?


it applies to any control in my app that has a border. However, i don''t want this theme to apply to my datagrids. How can i prevent this one from applying to my datagrids?
Thanks!

推荐答案

最简单的方法是为DataGrid设置样式,就像为所有边框设置样式一样,并且然后使用网格模板在其中更改边框的样式.
The easiest way to do this would be to set a style for your DataGrid, in much the same way you have set the style for all borders, and then change the styling of the border in there using the grid template.


这是一种更简单的方法:将控件包含在一个或多个类型为Border的嵌套边框中. br/>
让我向您展示一些技巧.这是如何使带有圆形边缘的凹陷边框的效果:

This is an easier and simpler way: enclose your control in one or more nested borders of the type Border.

Let me show you some trick. This is how to make the effect of recessed border with rounded edge:

<Border BorderThickness="1.2 1.2 0 0" CornerRadius="3.2" BorderBrush="Black" Margin="6" Padding="4">
    <Border BorderThickness="0 0 1.2 1.2" CornerRadius="3.2" BorderBrush="White">
        <!-- your content goes here -->
    </Border>
</Border> 



小数对获得更平滑的抗锯齿视图很重要.翻转黑色"和白色"以获得突出效果.

—SA



Fractional number are important to obtain smoother anti-aliased view. Flip "Black" and "White" to get a protruding effect.

—SA


这篇关于Datagrid的边框样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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