当前位置:网站首页>WPF 元素裁剪 Clip 属性
WPF 元素裁剪 Clip 属性
2022-08-04 18:38:00 【林德熙】
本文介绍如何在 WPF 使用 Clip 裁剪元素
在 WPF 的 UIElement 提供了 Clip 属性,这个属性默认是空,但是如果设置了这个属性就会对元素进行裁剪
这个属性是一个 Geometry 属性,设置的值表示裁剪之后剩下的部分,如写一个简单的类继承 UIElement 然后对他进行裁剪
class SisdecereYipuVayderyecallMawqere : UIElement
{
/// <inheritdoc />
public SisdecereYipuVayderyecallMawqere()
{
}
/// <inheritdoc />
protected override void OnRender(DrawingContext drawingContext)
{
drawingContext.DrawRectangle(Brushes.Black,null,new Rect(10,10,100,100));
}
}现在这个类会在 10,10 的坐标画出大小是 100 的矩形
对他裁剪,设置裁剪的是矩形裁剪
public SisdecereYipuVayderyecallMawqere()
{
Clip = new RectangleGeometry(new Rect(30, 30, 50, 50));
}从图片很难看出来不同,只是可以看到两个矩形,第一个矩形比较大
对他进行圆形裁剪
public SisdecereYipuVayderyecallMawqere()
{
Clip = new EllipseGeometry(new Point(30, 30), 10, 10);
}可以看到显示的是圆形
因为设置 Clip 属性是一个裁剪的窗口,只有在裁剪区域之内才可以显示
因为 Geometry 是可以做到不连续的,所以可以做出部分的透明,如裁剪两个矩形
public SisdecereYipuVayderyecallMawqere()
{
Geometry geometry = new RectangleGeometry(new Rect(10,10,10,10));
geometry = Geometry.Combine(geometry, new RectangleGeometry(new Rect(30, 30, 10, 10)),
GeometryCombineMode.Union, null);
Clip = geometry;
}上面代码使用 Geometry.Combine 合并两个图形
边栏推荐
- EasyCVR调用云端录像API接口返回错误且无录像文件生成,是什么原因?
- mq消息积压怎么对应
- ATF中断处理的设计模型
- ACP-Cloud Computing By Wakin自用笔记(2)CPU和内存虚拟化
- 全球电子产品需求放缓:三星越南工厂大幅压缩产能
- Hezhou Cat1 4G module Air724UG is configured with RNDIS network card or PPP dial-up, and the development board is connected to the Internet through the RNDIS network card (taking the RV1126/1109 devel
- win10 uwp 修改Pivot Header 颜色
- VPC2187/8 current mode PWM controller 4-100VIN ultra-wide voltage startup, highly integrated power control chip recommended
- 【web自动化测试】Playwright快速入门,5分钟上手
- 【STM32】STM32单片机总目录
猜你喜欢

BigDecimal 使用注意!!“别踩坑”

ECCV 2022 | FPN错位对齐,实现高效半监督目标检测(PseCo)

Matlab drawing 1

(ECCV-2022)GaitEdge:超越普通的端到端步态识别,提高实用性

EasyCVR calls the cloud recording API and returns an error and no recording file is generated. What is the reason?

通配符SSL证书不支持多域名吗?

【杰神说说】物联大师2.0版本预告

当项目中自动格式化插件Prettier和ESLint冲突报错时如何解决

入选爱分析·银行数字化厂商全景报告,网易数帆助力金融数字化场景落地

浅谈web网站架构演变过程
随机推荐
ros2订阅esp32发布的电池电压数据
如何封装 svg
MMDetection 使用示例:从入门到出门
Google Earth Engine APP——一键在线查看全球1984-至今年的影像同时加载一个影像分析
Literature Review on Involution of College Students
Global electronics demand slows: Samsung's Vietnam plant significantly reduces capacity
【CCIG 2022】视觉大模型论坛
基于激励的需求响应计划下弹性微电网的短期可靠性和经济性评估(Matlab代码实现)
ATF中断处理的设计模型
Those things about the curl command
2022 May 1 Mathematical Modeling Question C Explanation
数仓相关,总结
DHCP&OSPF组合实验演示(Huawei路由交换设备配置)
A group of friends asked for help, but the needs that were not solved in a week were solved in 3 minutes?
合宙Cat1 4G模块Air724UG配置RNDIS网卡或PPP拨号,通过RNDIS网卡使开发板上网(以RV1126/1109开发板为例)
Babbitt | Metaverse daily must-read: Weibo animation will recruit all kinds of virtual idols around the world and provide support for them...
VPC2187/8 current mode PWM controller 4-100VIN ultra-wide voltage startup, highly integrated power control chip recommended
Kubernetes入门到精通- Operator 模式入门
服务器
GBase8s存储过程