1my*_*myb 4 c# xaml microsoft-metro
我有一个按钮,我想在其上设置翻转动画效果和颜色的样式.但我无法使用Expression Blend打开文件.有没有办法设置当前XAML页面上的按钮的样式,而不是将所有内容插入控件库?
我想要一种颜色褪色效果,当用户将淡入淡出变为黑色时,当用户点击时,淡入淡出为白色.这是我到目前为止所拥有的
<Button Content="SOS" Foreground="White" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" Width="400" Margin="10,0,0,0" Background="#AE193E"
Padding="0" BorderThickness="0" FontSize="36" FontFamily="Calibri"
FontWeight="Normal" />
Run Code Online (Sandbox Code Playgroud)
好吧,我发现这= D
<Page.Resources>
<Style x:Key="CustomButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Orange"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontFamily" Value="Comic Sans MS"/>
<Setter Property="FontSize" Value="30"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<Storyboard>
<ColorAnimation Duration="0" To="LightGray" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="Border" />
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ColorAnimation Duration="0" To="Black" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="Border" />
<ColorAnimation Duration="0" To="White" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="Content" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid>
<Rectangle x:Name="Border" Stroke="Black" Fill="Orange" Margin="-5"/>
<ContentPresenter x:Name="Content"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
Run Code Online (Sandbox Code Playgroud)
并将这个小短代码添加到那里的按钮
Style="{StaticResource CustomButtonStyle}"
Run Code Online (Sandbox Code Playgroud)
现在才发现那里的地铁aps样品......
| 归档时间: |
|
| 查看次数: |
5389 次 |
| 最近记录: |