<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ScreenGlintApplication.Window1" x:name="Window" title="Window1" WIDth="500" Height="250" Background="#FF000000" Foreground="#FF3EE229" > <GrID x:name="LayoutRoot"> <TextBlock textwrapPing="Wrap" FontSize="40" > <Run Text="This is some sample text to have something to work with. Have a nice day! /Johan"/> </TextBlock> <Canvas Panel.ZIndex="99" > <Rectangle x:name="ScreenGlintrect" WIDth="{Binding Path=ActualWIDth,Elementname=Window,Mode=Default}" Height="{Binding Path=ActualHeight,Mode=Default}" Opacity="0.4" > <Rectangle.Triggers> <EventTrigger RoutedEvent="Rectangle.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.Targetname="ScreenGlintrect" Storyboard.TargetProperty="(Canvas.left)" From="-500" To="1000" Duration="0:0:2" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Rectangle.Triggers> <Rectangle.Fill> <linearGradIEntBrush StartPoint="0,1" EndPoint="1,1"> <GradIEntStop color="transparent" Offset="0.0" /> <GradIEntStop x:name="Glintcolor" color="lightGreen" Offset="0.50" /> <GradIEntStop color="transparent" Offset="1" /> </linearGradIEntBrush> </Rectangle.Fill> </Rectangle> </Canvas> </GrID></Window>
一个选项是在后面的代码中执行此 *** 作,如果您想要对动画进行精细控制,这非常简洁.例如:
ScreenGlintrect.WIDth = WIDth; ScreenGlintrect.Height = Height; var animation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(2)),From = (-WIDth),To = WIDth * 2 }; ScreenGlintrect.BeginAnimation(Canvas.leftProperty,animation);
这是我正在使用的代码,它对我来说看起来不错.如果你有硬件加速,你可以尝试添加一些模糊.您可能需要调整代码并隐藏/显示矩形,但基本上就是这样.
总结以上是内存溢出为你收集整理的WPF或Silverlight中的屏幕闪烁效果全部内容,希望文章能够帮你解决WPF或Silverlight中的屏幕闪烁效果所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)