动画在WPF后台控制? [英] Animated background control in WPF?
本文介绍了动画在WPF后台控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的WPF应用程序,我想也有类似的环境动画背景,以媒体中心的背景。有一个免费的控制,提供了吗?
In my WPF application, I want to have an ambient animated background similar to Media Center's background. Is there a free control that offers this?
推荐答案
我想preFER通过故事板动画边框的背景。这是pretty容易,只要你喜欢,你可以建立一个动画一样复杂。下面是一个简单的例子:
I would prefer to animate the background of a border via storyboard. It's pretty easy and you can build a animation as complex as you like. Here is a short example:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard AutoReverse="True" BeginTime="0" >
<DoubleAnimation Storyboard.TargetName="Foo"
Storyboard.TargetProperty="Offset"
From="0.2" To="0.8" Duration="0:0:10"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
<Border>
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Yellow" Offset="0"/>
<GradientStop Color="Orange" Offset="0.2" x:Name="Foo"/>
<GradientStop Color="Red" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<!-- put your windowcontent(grid etc.) here -->
</Border>
</Window>
您也应该看到MSDN文章的 动画概述 的
You should also see the MSDN article Animation Overview.
这篇关于动画在WPF后台控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文