WPF邊框不同形式的設(shè)置技巧
作者:佚名
WPF邊框的設(shè)置方法要向熟練的掌握,首先就需要通過(guò)實(shí)踐去不斷積累經(jīng)驗(yàn),來(lái)牢固我們已經(jīng)掌握的書面知識(shí)。
WPF開發(fā)工具為我們帶來(lái)了不一樣的編程環(huán)境。對(duì)于這樣一款新型的圖形界面處理工具,有許多地方值得我們?nèi)W(xué)習(xí)。現(xiàn)在我們先來(lái)了解下WPF邊框相關(guān)設(shè)置方法。#t#
WPF邊框設(shè)置樣式代碼示例:
- < 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>
定義相應(yīng)的WPF邊框樣式資源:
RacePitBackgroundBrush
RacePitBorderBrush
類型是WPF邊框,設(shè)置相應(yīng)的屬性如下:
Background
BorderBrush
BorderThickness
CornerRadius
Margin
責(zé)任編輯:曹凱
來(lái)源:
博客園