当前位置:网站首页>14、wpf之Border装饰器使用小记
14、wpf之Border装饰器使用小记
2022-06-13 11:38:00 【komla168】
一、简介
Border是一个装饰器控件, 用于在另一个元素四周绘制边框或背景。
Border只能包含一个控件,如果想包含多个控件需要中间加一层,让Border去包含一个布局控件,布局控件再包含其他控件。
二、常用属性
既然是装饰器,就是对所包含控件的四周做些操作,常用的这么几个:边框颜色、厚度、边框背景,这些 属性一般都在一起使用。
2.1 边框颜色和厚度(BorderBrush/BorderThickness)
默认边框厚度是0,所以单独设置边框颜色是看不到什么效果的,需要把边框厚度设置下才能看到。
<Grid Margin="10">
<Border BorderBrush="Red" BorderThickness="2">
<StackPanel Margin="10">
<Button Content="fengtun"/>
<Button Content="jioabi"/>
<Button Content="yanggaoxiong"/>
</StackPanel>
</Border>
</Grid>
这个边框厚度值可以分别设置上下左右四个方向的
<Grid Margin="10">
<Border BorderBrush="Red" BorderThickness="1 5 10 20">
<StackPanel Margin="10">
<Button Content="engtun"/>
<Button Content="jioabi"/>
<Button Content="anggaoxiong"/>
</StackPanel>
</Border>
</Grid>
2.2 圆角(CornerRadius)
设置Border的角倒圆的程度,同样的可以分别设置4个角的值
<Border BorderBrush="Red" BorderThickness="1 5 10 20" CornerRadius="1,5,10,20">
<StackPanel Margin="10">
<Button Content="engtun"/>
<Button Content="jioabi"/>
<Button Content="anggaoxiong"/>
</StackPanel>
</Border>
2.3 边框背景(Background)
Background 属性属于 Brush 类型,所以可操作性非常强,处理使用简单的颜色之外,还可以使用渐变色作为背景。
<Grid Margin="10">
<Border BorderBrush="Red" BorderThickness="1 5 10 20" CornerRadius="1,5,10,20">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#1ca6ff" Offset="0.5"/>
<GradientStop Color="#f8024e" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<StackPanel Margin="10">
<Button Content="engtun"/>
<Button Content="jioabi"/>
<Button Content="anggaoxiong"/>
</StackPanel>
</Border>
</Grid>
三、引用文献
边栏推荐
- 【TcaplusDB知识库】TcaplusDB集群管理介绍
- MIIdock文件分布
- Nim game ladder Nim game and SG function application (set game)
- 【TcaplusDB知识库】TcaplusDB单据受理-建表审批介绍
- How to use dataX to update the data in the downstream Oracle database with the update semantics?
- Pyepics download and installation
- (Yousheng small message-04) how to use mobile WPS for electronic signature on PDF
- Ipdu handling caused by mode change of COM
- How vscode converts a tab key in an edited file into a spacebar
- Idea usage
猜你喜欢
Camunda timer events example demo (timer events)
Mac 安装 MySQL 教程
【TcaplusDB知识库】TcaplusDB单据受理-创建游戏区介绍
What is the appropriate setting for the number of database connections?
[tcapulusdb knowledge base] tcapulusdb tmonitor module architecture introduction
ARM64 上的性能怪兽:API 网关 Apache APISIX 在 AWS Graviton3 上的安装和性能测试
Process of manually encrypting and burning the mass production firmware of ESP equipment
【TcaplusDB知识库】TcaplusDB单据受理-建表审批介绍
C#/VB. Net to generate directory bookmarks when word is converted to PDF
燃油方案和产品业务建模
随机推荐
22、ADS使用记录之E类功放设计(下)
Will it be a great opportunity for entrepreneurs for Tiktok to attach so much importance to live broadcast sales of takeout packages?
Web 3.0? High cost version of P2P
[tcapulusdb knowledge base] tcapulusdb cluster management introduction
(small information for children to children-03) batch template production of basic information collection folder for children (including PDF, word and certificate folder)
Query the current number of computer CPU cores
F2. nearest beautiful number (hard version)
面试题 Mysql 数据库
Ipdu handling caused by mode change of COM
『忘了再学』Shell基础 — 30、sed命令的使用
camunda如何使用script脚本节点
Based on vue+nest Js+mysql cross platform open source community operation management system
Gauss elimination for solving N-element equations
LVGL库入门教程01-移植到STM32(触摸屏)
【TcaplusDB知识库】Tmonitor系统升级介绍
To avoid letting the transformation enterprises go astray, it is time to re understand the integration of xiahu warehouse| Q recommendation
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
Kubernetes deploying ActiveMQ
面试技巧问答
fastapi 如何响应文件下载