我自己重写了按钮,按钮是浅红色。
我想要的效果是,当鼠标进入按钮区域后,按钮慢慢地重浅红色,变成深红色。该怎么实现?有没有例子?关键要解决的是,如何慢慢变成深红色,而不是瞬间变成深红色。
我想要的效果是,当鼠标进入按钮区域后,按钮慢慢地重浅红色,变成深红色。该怎么实现?有没有例子?关键要解决的是,如何慢慢变成深红色,而不是瞬间变成深红色。
解决方案 »
- OutOfMemoryExceptions while remoting very large datasets,由于数据太大无法通过remoting传递
- 求救,关于死循环里异步调用导致内存溢出的问题
- 如何从多个字段中搜索值?
- 流量控制问题
- 如何给Page.LoadControl加载的用户控件附值?
- C#里面怎么调用.h头文件和.lib库文件?或者C#里面调用由VB编写的DLL
- 与数据库相连的有关问题
- [请教]Hashtable的使用。
- 无法创建C# Project,大家来帮个忙
- c#怎么写ocx控件,我看那几个工程编译后都不是ocx的文件
- System.NullReferenceException: 未将对象引用设置到对象的实例?
- RDLC多层钻取方法
<Setter Property="Background" Value="Blue" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Yellow" />
</Trigger>
</Style.Triggers>
</Style>
找到了。你们都错了,不用写线程。直接写Xaml样式就可以了。<Window.Resources> <ResourceDictionary> <ControlTemplate x:Key="mystyle" TargetType="{x:Type Button}"> <ControlTemplate.Resources> <Storyboard x:Key="Timeline1"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)"> <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="Timeline2"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)"> <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </ControlTemplate.Resources> <Border BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4"> <Border x:Name="border" Background="#00000000" BorderBrush="#FF000000" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="0.507*"/> <RowDefinition Height="0.493*"/> </Grid.RowDefinitions> <Border Opacity="0" Background="Red" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2" CornerRadius="4,4,4,4"> </Border> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" Grid.RowSpan="2"/> <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="shine" Width="Auto" CornerRadius="4,4,4,4"> </Border> </Grid> </Border> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource Timeline1}"/> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard x:Name="Timeline2_BeginStoryboard" Storyboard="{StaticResource Timeline2}"/> </Trigger.ExitActions> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </ResourceDictionary> </Window.Resources> <Grid> <StackPanel> <Button Content="Funktionsliste1" VerticalAlignment="Center" Template="{DynamicResource ResourceKey=mystyle}"/> <Button Content="Funktionsliste2" VerticalAlignment="Center" Template="{DynamicResource ResourceKey=mystyle}"/> </StackPanel> </Grid>