什么是WPF
WPF(Windows Presentation Foundation)是微软推出的基于Windows 的用户界面框架,属于.NET Framework 3.0的一部分。它提供了统一的编程模型、语言和框架,真正做到了分离界面设计人员与开发人员的工作;同时它提供了全新的多媒体交互用户图形界面。
在没给大家介绍实现代码之前,先给大家看下效果图,如果大家感觉效果不错,请参考实现代码:
XAML代码:
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
|
<ControlTemplate x:Key= "btnTpl" TargetType= "RadioButton" >
<StackPanel Orientation= "Vertical" Height= "30" Background= "Transparent" >
<Border Name= "border" Background= "#006AB8" Height= "25" >
<ContentPresenter Name= "contentPre" VerticalAlignment= "Center" HorizontalAlignment= "Center" TextElement.Foreground= "#FFF" TextElement.FontSize= "12" Margin= "0" />
</Border>
<Path x:Name= "path" HorizontalAlignment= "Center" VerticalAlignment= "Center" Data= "M 0 0 L 6 4 L 12 0 Z" >
<Path.Fill>
<SolidColorBrush Color= "#006AB8" />
</Path.Fill>
</Path>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property= "IsMouseOver" Value= "True" >
<Setter TargetName= "border" Property= "Margin" Value= "2 2 2 0" ></Setter>
<Setter TargetName= "border" Property= "Height" Value= "23" ></Setter>
<Setter Property= "TextElement.FontSize" Value= "11" ></Setter>
</Trigger>
<Trigger Property= "IsChecked" Value= "true" >
<Setter TargetName= "border" Property= "Border.Background" Value= "#15BDF7" ></Setter>
<Setter TargetName= "path" Property= "Fill" >
<Setter.Value>
<SolidColorBrush Color= "#15BDF7" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
|
总结
以上所述是小编给大家介绍的WPF制作带小箭头的按钮完整代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!
原文链接:http://www.cnblogs.com/s0611163/archive/2017/12/06/7991393.html