Xaml 如何设计类似按钮的应用程序栏按钮
我创造了一种风格,它在某种程度上符合我所寻找的,事实上它确实有效。但是,我需要更新样式,以便可以在多个按钮上使用它,而不仅仅是一个按钮。目前,我将按钮源代码放在样式本身中,我希望能够将样式应用于页面上按钮实际存在的位置。这是我目前正在做的,但只适用于一个按钮。此外,此样式与默认应用程序栏样式不完全匹配,根据我所知,无论颜色是浅还是深,该样式都会使用设备强调色填充圆圈,并且按钮内的图标保持白色,我如何更新解决方案Xaml 如何设计类似按钮的应用程序栏按钮,xaml,button,windows-phone-8,styles,Xaml,Button,Windows Phone 8,Styles,我创造了一种风格,它在某种程度上符合我所寻找的,事实上它确实有效。但是,我需要更新样式,以便可以在多个按钮上使用它,而不仅仅是一个按钮。目前,我将按钮源代码放在样式本身中,我希望能够将样式应用于页面上按钮实际存在的位置。这是我目前正在做的,但只适用于一个按钮。此外,此样式与默认应用程序栏样式不完全匹配,根据我所知,无论颜色是浅还是深,该样式都会使用设备强调色填充圆圈,并且按钮内的图标保持白色,我如何更新解决方案 <Style x:Key="ButtonStyle1" TargetType=
<Style x:Key="ButtonStyle1" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
<Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
<Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
<Setter Property="Padding" Value="10,3,10,5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="circleBorder">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="rectangle">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="circleBorder">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="rectangle">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="0" Margin="{StaticResource PhoneTouchTargetOverhang}">
<Grid >
<Rectangle x:Name="rectangle" Fill="{StaticResource PhoneForegroundBrush}">
<Rectangle.OpacityMask>
<ImageBrush ImageSource="/Assets/Map/appbar.location.round.png"/>
</Rectangle.OpacityMask>
</Rectangle>
<Ellipse x:Name="circleBorder" Stroke="{StaticResource PhoneForegroundBrush}" StrokeThickness="3"/>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
...
<Button x:Name="MimicAppBarButton" Width="76" Height="76"
HorizontalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ButtonStyle1}" BorderBrush="Transparent"
toolkit:TiltEffect.IsTiltEnabled="True" Click="MimicAppBarButton_Click">
...
您好,您可以使用它。它有一个类似于appbar按钮的圆形控制按钮。谢谢,如何更改圆形按钮控件中的图像?它默认为选中标记。设置“ImageSource”属性不会像在默认应用程序栏按钮中一样,将我正在使用的图标图像保持在周围椭圆的边界内。