日期:2014-05-18 浏览次数:21295 次
<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Ellipse x:Name="ellipse" Fill="#FFF4F4F5" Stroke="Black"/> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsFocused" Value="True"/> <Trigger Property="IsDefaulted" Value="True"/> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Fill" TargetName="ellipse" Value="Blue"/> </Trigger> <Trigger Property="IsPressed" Value="True"/> <Trigger Property="IsEnabled" Value="False"/> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
------解决方案--------------------
最简单的方法:
新建一个圆,如图片填充
<Ellipse Stroke="#FF000000" StrokeThickness="0"> <Ellipse.Fill> <ImageBrush ImageSource="msgsys_warn.png" Stretch="Uniform"/> </Ellipse.Fill> </Ellipse>
------解决方案--------------------
不用,你图片做成PNG即可,透明区域不会响应
参考下图
http://nonocast.cn/?attachment_id=4336
------解决方案--------------------
使用Blend来制作,想变成什么样的按钮,就能实现什么样的按钮!
做WPF、Silverlight开发,Blend基本操作必须会!
------解决方案--------------------