无废话WPF系列18:控件模版
2011-02-27 11:15 敏捷的水 阅读(1128) 评论(0) 编辑 收藏 举报控件模版ControlTemplate就是设置控件的外观,比如我们常见到的按钮是下面这样的,但是我们如何改变成圆形的呢?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | < Window x:Class="DeepXAML.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DeepXAML" xmlns:sys="clr-namespace:System;assembly=mscorlib" Title="MainWindow" Height="250" Width="450"> < Window.Resources > < Style x:Key="roundButton" TargetType="Button"> < Setter Property="Background"> < Setter.Value > < LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> < LinearGradientBrush.GradientStops > < GradientStop Offset="0.0" Color="#fff" /> < GradientStop Offset="1.0" Color="Red" /> </ LinearGradientBrush.GradientStops > </ LinearGradientBrush > </ Setter.Value > </ Setter > < Setter Property="Template"> < Setter.Value > < ControlTemplate TargetType="Button"> < Grid > < Ellipse Fill="{TemplateBinding Background}"></ Ellipse > < ContentPresenter Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" /> </ Grid > </ ControlTemplate > </ Setter.Value > </ Setter > </ Style > </ Window.Resources > < StackPanel x:Name="stackPanel"> < Button Width="200" Height="120" Margin="20" Style="{StaticResource ResourceKey=roundButton}">OK</ Button > </ StackPanel > </ Window > |
ItemsControl有个PanelTemplate可以控制ItemsControl的条目容器。
扫码关注公众号,了解更多管理,见识,育儿等内容

作者: 王德水
出处:http://www.cnblogs.com/cnblogsfans
版权:本文版权归作者所有,转载需经作者同意。
出处:http://www.cnblogs.com/cnblogsfans
版权:本文版权归作者所有,转载需经作者同意。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
2008-02-27 ten sentences(91-100)
2008-02-27 ten sentences(81-90)
2008-02-27 ten sentences(71-80)
2008-02-27 ten sentences(61-70)
2008-02-27 ten sentences(51-60)