在用XAML佈局的時候,有時候為了讓介面Metro化,有些Button要使用圓形來取代預設的長方形。以下的Button樣式可以解決這個問題,可以依照自己的需求再加以修改。當然如果你熟悉Bland的話可以直接使用它來繪製你需要的樣式,但是貼程式碼是否更快一點呢? 複製程式碼程式碼如下: <br /> <Setter Property="Template"><br /> <Setter.Value><br /> <ControlTemplate TargetType="Button"><br /> <Grid><br /> <VisualStateManager.VisualStateGroups> <br /> <VisualStateGroup x:Name="CommonStates"><br /> <VisualState x:Name="Pressed"><br /> <Storyboard><br /> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard. TargetName="rectangle"><br /> <DiscreteObjectKeyFrame KeyTime="0"><br /> <DiscreteObjectKeyFrame.Value><br /> <Thickness>-3<br /> <br /> < /DiscreteObjectKeyFrame><br /> <br /> <br /> <br /> <VisualState x:Name="Normal"/><br /> <VisualState x:Name="Disable x:Name="Disable x" /><br /> <VisualState x:Name="MouseOver"/><br /> <br /> <VisualStateGroup x:Name="FocusStates"><br /> <VisualState x:Name="Focused"/> <br /> <br /> <br /> <Rectangle x:Name="rectangle" RadiusY="25" RadiusX="25" Stroke="Blue" StrokeThickness="4"><br /> <br /> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/><br /> Value><br /> <br /> <Setter Property="Margin" Value="5"/><br /> <Setter Property="Width" Value="50"/><br /> <Setter Property= "Height" Value="50"/><br /> <Setter Property="FontSize" Value="120"/><br /> <Setter Property="Foreground" Value="White"/><br />