去除WPF中GroupBox边框的白边
来源:互联网 发布:js判断变量undefined 编辑:程序博客网 时间:2024/05/23 16:56
使用WPF中的GroupBox控件时,如果背景色不是白色,那么会在GroupBox边框出现白边,如图1所示:
图1
经过一番网上搜索,最终发现解决方法:“WPF――――4.去除GroupBox白色间隔”,效果如图2所示:
图2
代码如下:
<Window.Resources> <BorderGapMaskConverter x:Key="BorderGapMaskConverter"/> <Style x:Key="GroupboxWithoutWhiteBorder" TargetType="{x:Type GroupBox}"> <Setter Property="BorderBrush" Value="#D5DFE5" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupBox}"> <Grid SnapsToDevicePixels="true"> <Grid.ColumnDefinitions> <ColumnDefinition Width="6" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="6" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> <RowDefinition Height="6" /> </Grid.RowDefinitions> <Border CornerRadius="4" Grid.Row="1" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" Background="{TemplateBinding Background}" /> <Border Name="Header" Padding="3,1,3,0" Grid.Row="0" Grid.RowSpan="2" Grid.Column="1"> <ContentPresenter ContentSource="Header" RecognizesAccessKey="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> </Border> <ContentPresenter Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> <Border Grid.Row="1" Grid.RowSpan="3" Grid.ColumnSpan="4" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="3"> <Border.OpacityMask> <MultiBinding Converter="{StaticResource BorderGapMaskConverter}" ConverterParameter="7"> <Binding ElementName="Header" Path="ActualWidth" /> <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" /> <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" /> </MultiBinding> </Border.OpacityMask> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid Background="Green"> <GroupBox Header="WPF边框白边" Margin="20" Style="{StaticResource GroupboxWithoutWhiteBorder}"/> </Grid>
项目下载
0 1
- 去除WPF中GroupBox边框的白边
- GroupBox去除边框
- C#中更改groupbox的边框的颜色
- 微软的GroupBox边框颜色的改变 ~!
- winform c# groupBox 的边框颜色
- winform c# groupBox 的边框颜色
- C#:如何去掉groupbox的边框线
- wpf中无边框窗体的问题
- 去除iframe的边框
- 去除Iframe的边框
- 去除按钮的边框
- 去除GUIButton的边框
- 去除图片的边框
- WPF 窗口去除顶部边框(正宗无边框)
- winform c# 重绘groupBox 的边框颜色
- 用HTML轻松实现GroupBox的边框效果
- WPF控件之GroupBox
- Word中去除表格边框
- Linux学习-pstree,htop,glances,dstat 命令使用
- Java 时间类-Calendar、Date、LocalDate/LocalTime
- jQuery中的100个技巧
- MySQL事务隔离级别详解
- Hbase无法关闭
- 去除WPF中GroupBox边框的白边
- 第十六周课后作业——项目二——学生成绩处理(1)
- 【项目2-学生成绩处理】
- KMP算法next数组
- js或Jquery 根据字符串类型的方法名,找到对应的方法并且调用
- ab
- sudo apt-get update:Could not get lock /var/lib/apt/lists/lock解决办法
- guava之Joiner 和 Splitter
- js 实时监听input中值变化