现在,我可以将按钮的外观更改为具有背景图像的椭圆形。 但是,当我点击它时,我不觉得Silverlight中的正常按钮的点击效果 任何人都可以帮助我如何获得该效果?如何创建带图像背景的圆形按钮和点击感觉Silverlight
这是我的圆形按钮
<style x:Key="roundButton" TargetType="Button">
<Setter Properties="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Ellipse width="100" height="100">
<Ellipse.Fill>
<ImageBrush ImageSource="./icon.png">
</Ellipse.Fill>
</Ellipse>
</ControlTemplate>
</Setter.Value>
</Setter>
</style>
摸索我知道我应该在Systems.Window使用VisualStateManager后XAML的风格。这是我的XAML现在的样子,但我仍然不能得到像普通按钮
<Style x:Key="roundButton" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Width="100" Height="100">
<Ellipse.Fill>
<ImageBrush ImageSource="./icon.png" />
</Ellipse.Fill>
</Ellipse>
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="MouseOver"/>
<vsm:VisualState x:Name="Normal"/>
<vsm:VisualState x:Name="Pressed"/>
<vsm:VisualState x:Name="Disabled"/>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="FocusStates">
<vsm:VisualState x:Name="Unfocused"/>
<vsm:VisualState x:Name="Focused"/>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
您好,我很抱歉没有提及,我想这样做在Silverlight不上头。 ControlTemplate.Triggers将不会被找到。我应该怎么做才能让它得到承认。 – Tai 2010-09-08 17:36:31