WPF边框不同形式的设置技巧

开发 开发工具
WPF边框的设置方法要向熟练的掌握,首先就需要通过实践去不断积累经验,来牢固我们已经掌握的书面知识。

WPF开发工具为我们带来了不一样的编程环境。对于这样一款新型的图形界面处理工具,有许多地方值得我们去学习。现在我们先来了解下WPF边框相关设置方法。#t#

WPF边框设置样式代码示例:

  1. < ResourceDictionary   
  2. xmlns="http://schemas.microsoft.
    com/winfx/2006/xaml/presentation"
     
  3. xmlns:x="http://schemas.microsoft.
    com/winfx/2006/xaml"
     
  4. > 
  5. < Style x:Key="RacePitBorderStyle" 
    TargetType="Border"> 
  6. < Style.Resources> 
  7. < LinearGradientBrush x:Key=
    "RacePitBackgroundBrush" StartPoint=
    "0.5,0" EndPoint="0.5,1"> 
  8. < GradientStop Color="#88000000" 
    Offset="0.1" /> 
  9. < GradientStop Color="#CC000000" 
    Offset="0.9" /> 
  10. < /LinearGradientBrush> 
  11. < LinearGradientBrush x:Key=
    "RacePitBorderBrush" StartPoint=
    "0.5,0" EndPoint="0.5,1"> 
  12. < GradientStop Color="#18000000" 
    Offset="0.1" /> 
  13. < GradientStop Color="#08000000" 
    Offset="0.9" /> 
  14. < /LinearGradientBrush> 
  15. < /Style.Resources> 
  16. < Setter Property="Background" 
    Value="{StaticResource RacePit
    BackgroundBrush}"
     /> 
  17. < Setter Property="BorderBrush" 
    Value="{StaticResource RacePit
    BorderBrush}"
     /> 
  18. < Setter Property="BorderThic
    kness"
     Value="1" /> 
  19. < Setter Property="CornerRadius" 
    Value="8" /> 
  20. < Setter Property="Margin" 
    Value="2,4" /> 
  21. < /Style> 
  22. < /ResourceDictionary> 

 

定义相应的WPF边框样式资源:

RacePitBackgroundBrush

RacePitBorderBrush

类型是WPF边框,设置相应的属性如下:

Background

BorderBrush

BorderThickness

CornerRadius

Margin

责任编辑:曹凯 来源: 博客园
相关推荐

2018-05-22 14:19:21

数据虚拟化形式

2009-12-25 10:20:28

WPF窗口

2009-12-15 16:41:17

路由器设置

2009-07-02 13:40:45

面试

2009-12-25 17:39:01

WPF验证

2010-01-05 17:52:34

JSON形式

2009-12-23 17:07:37

WPF性能

2013-11-28 09:43:46

JavaScriptWeb

2023-05-15 08:18:21

CSS技巧代码

2009-12-24 09:38:27

WPF用户线程

2009-12-28 15:01:39

WPF树应用

2009-12-23 15:16:52

WPF数据绑定

2009-12-23 14:30:24

WPF显示动态GIF

2011-02-24 09:50:28

EmeraldUbuntu

2010-07-13 10:10:28

WPF

2009-12-25 09:44:52

WPF窗口设置

2009-12-28 10:40:13

WPF调用Winfor

2009-12-29 11:01:46

WPF淡入效果

2010-03-01 13:50:35

Visual Stud

2009-12-23 10:35:55

WPF应用程序项目
点赞
收藏

51CTO技术栈公众号