WPF开发工具为我们带来了不一样的编程环境。对于这样一款新型的图形界面处理工具,有许多地方值得我们去学习。现在我们先来了解下WPF边框相关设置方法。#t#
WPF边框设置样式代码示例:
- < ResourceDictionary
- xmlns="http://schemas.microsoft.
com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.
com/winfx/2006/xaml"
- >
- < Style x:Key="RacePitBorderStyle"
TargetType="Border">
- < Style.Resources>
- < LinearGradientBrush x:Key=
"RacePitBackgroundBrush" StartPoint=
"0.5,0" EndPoint="0.5,1">
- < GradientStop Color="#88000000"
Offset="0.1" />
- < GradientStop Color="#CC000000"
Offset="0.9" />
- < /LinearGradientBrush>
- < LinearGradientBrush x:Key=
"RacePitBorderBrush" StartPoint=
"0.5,0" EndPoint="0.5,1">
- < GradientStop Color="#18000000"
Offset="0.1" />
- < GradientStop Color="#08000000"
Offset="0.9" />
- < /LinearGradientBrush>
- < /Style.Resources>
- < Setter Property="Background"
Value="{StaticResource RacePit
BackgroundBrush}" />
- < Setter Property="BorderBrush"
Value="{StaticResource RacePit
BorderBrush}" />
- < Setter Property="BorderThic
kness" Value="1" />
- < Setter Property="CornerRadius"
Value="8" />
- < Setter Property="Margin"
Value="2,4" />
- < /Style>
- < /ResourceDictionary>
定义相应的WPF边框样式资源:
RacePitBackgroundBrush
RacePitBorderBrush
类型是WPF边框,设置相应的属性如下:
Background
BorderBrush
BorderThickness
CornerRadius
Margin