C# 如何编辑故事板以使其成为按钮样式?
我已经为混合中的按钮创建了一个故事板,我希望它在每次按下按钮时都应用,所以我尝试创建一个样式,我已经被卡住很久了 以下是我的故事板的代码:C# 如何编辑故事板以使其成为按钮样式?,c#,xaml,expression-blend,windows-phone-7,storyboard,C#,Xaml,Expression Blend,Windows Phone 7,Storyboard,我已经为混合中的按钮创建了一个故事板,我希望它在每次按下按钮时都应用,所以我尝试创建一个样式,我已经被卡住很久了 以下是我的故事板的代码: <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Stor
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)"
Storyboard.TargetName="button">
<EasingDoubleKeyFrame KeyTime="0"
Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:0.25"
Value="0.85">
<EasingDoubleKeyFrame.EasingFunction>
<QuinticEase EasingMode="EaseInOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:0.5"
Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<QuarticEase EasingMode="EaseIn" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)"
Storyboard.TargetName="button">
<EasingDoubleKeyFrame KeyTime="0"
Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:0.25"
Value="0.85">
<EasingDoubleKeyFrame.EasingFunction>
<QuinticEase EasingMode="EaseInOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:0.5"
Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<QuarticEase EasingMode="EaseIn" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
下面是我的按钮样式代码:
<Style x:Key="ParametersButton"
TargetType="ButtonBase">
<Setter Property="Background"
Value="{StaticResource TransparentBrush}" />
<Setter Property="BorderBrush"
Value="{StaticResource PhoneForegroundBrush}" />
<Setter Property="Foreground"
Value="{StaticResource PhoneForegroundBrush}" />
<Setter Property="MinHeight"
Value="72" />
<Setter Property="BorderThickness"
Value="{StaticResource PhoneDefaultBorderThickness}" />
<Setter Property="FontFamily"
Value="{StaticResource PhoneFontFamilyNormal}" />
<Setter Property="FontSize"
Value="{StaticResource PhoneFontSizeMediumLarge}" />
<Setter Property="Padding"
Value="0,15,15,0" />
<Setter Property="Height"
Value="72" />
<Setter Property="Width"
Value="72" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ButtonBase">
<Grid Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver" />
<VisualState x:Name="UnPressed" />
<VisualState x:Name="Pressed">
<Storyboard>
<!--Here is where I want to insert my StoryBoard-->
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled" />
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused" />
<VisualState x:Name="Unfocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="ButtonBackground"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0"
CornerRadius="0"
Background="#FF1BA1E2"
Margin="{StaticResource PhoneTouchTargetOverhang}"
RenderTransformOrigin="0.5,0.5">
<ContentControl x:Name="foregroundContainer"
FontFamily="{TemplateBinding FontFamily}"
Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
FontSize="{TemplateBinding FontSize}"
Padding="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我怎样才能继续
谢谢
Renaud在Expression Blend中最简单,编辑样式时,选择所需的视觉状态,打开情节提要面板并创建动画。这将在您进入该状态时触发
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="Background"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="00:00:00"
Value="White" />
<EasingColorKeyFrame KeyTime="00:00:01"
Value="Red" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualState x:Name="Pressed" />
<VisualState x:Name="Disabled" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
在Expression Blend中最简单的方法是,在编辑样式时,选择所需的视觉状态,打开“情节提要”面板并创建动画。这将在您进入该状态时触发
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="Background"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="00:00:00"
Value="White" />
<EasingColorKeyFrame KeyTime="00:00:01"
Value="Red" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualState x:Name="Pressed" />
<VisualState x:Name="Disabled" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
Wall of text crits you for 50kI抱歉,但我完全不明白你刚才说的话。这只是一个玩笑。基本上,当你想询问一些事情时,发布一些代码是很好的(这证明你不是在要求社区为你解决问题),但是发布大约两页代码不是很有吸引力。请确保您发布社区了解问题并帮助您解决问题所需的内容。为什么要用Windows Mobile标记此内容?据我所知,WindowsMobile实际上不支持XAML.WindowsPhone7,但目前还不存在WP7标签。对不起,我有过多地使用邮政编码的倾向,但我的问题似乎更清楚。你们谁也帮不了我?文字墙让你们受了50千分之五对不起,但我一点也不明白你们刚才说的话。这只是个玩笑。基本上,当你想询问一些事情时,发布一些代码是很好的(这证明你不是在要求社区为你解决问题),但是发布大约两页代码不是很有吸引力。请确保您发布社区了解问题并帮助您解决问题所需的内容。为什么要用Windows Mobile标记此内容?据我所知,WindowsMobile实际上不支持XAML.WindowsPhone7,但目前还不存在WP7标签。对不起,我有过多地使用邮政编码的倾向,但我的问题似乎更清楚。你们谁也帮不了我?