在WPF中自动从左到右移动标签

编程入门 行业动态 更新时间:2024-10-27 12:40:20
本文介绍了在WPF中自动从左到右移动标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨 我是WPF的新手我的问题是如何在WPF应用程序中自动从左到右移动标签 谢谢和问候 Indrajit

Hi I am new to WPF my question is how to auto move a label left to right in WPF application Thanks & regards Indrajit

推荐答案

void Window1_Loaded(object sender,RoutedEventArgs e) $ DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.From = -tbmarquee.ActualWidth; doubleAnimation.To = canMain.ActualWidth; doubleAnimation.RepeatBehavior = RepeatBehavior.Forever; doubleAnimation.Duration = new Duration(TimeSpan.Parse(0:0:10)); tbmarquee.BeginAnimation(Canvas.LeftProperty,doubleAnimation); } // xaml < window x:class =MarqueText.Window1xmlns:x =#unknown > xmlns =schemas.microsoft/winfx/2006/xaml/presentation xmlns:x = schemas.microsoft/winfx/2006/xaml Title =Window1Height =500Width =700> < canvas background =White> < canvas margin =50 canvas.left =150canvas.top =100cliptobounds =Truename =canMainbackground =Redheight =100width =300> < textblock margin =0,40fontsize =25name =tbmarquee>孟加拉国 < / canvas> ; < / canvas> 从左到右选框:使用画布左侧属性 左选框:使用画布的右属性 对于向上选框:使用画布的底部属性 Fo r向下选框:使用画布的顶级属性 < textblock grid.row =2fontsize =22 name =txtScrolling> < textblock.rendertransform> < translatetransform x:name =translatexmlns:x =#unknown> < textblock.triggers> < eventtrigger routedevent =FrameworkElement.Loaded> < beginstoryboard> < storyboard repeatbehavior =Forever> < doubleanimation> From =1200To = - 1200 Storyboard.TargetName =翻译 Storyboard.TargetProperty =X 持续时间=0:0:9/> 这是滚动的文字 void Window1_Loaded(object sender, RoutedEventArgs e) { DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.From = -tbmarquee.ActualWidth; doubleAnimation.To = canMain.ActualWidth; doubleAnimation.RepeatBehavior = RepeatBehavior.Forever; doubleAnimation.Duration = new Duration(TimeSpan.Parse("0 : 0 : 10")); tbmarquee.BeginAnimation(Canvas.LeftProperty, doubleAnimation); } // xaml <window x:class="MarqueText.Window1" xmlns:x="#unknown"> xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/winfx/2006/xaml" Title="Window1" Height="500" Width="700" > <canvas background="White"> <canvas margin="50" canvas.left="150" canvas.top="100" cliptobounds="True" name="canMain" background="Red" height="100" width="300"> <textblock margin="0,40" fontsize="25" name="tbmarquee">Bangladesh </canvas> </canvas> For Left to right marquee: use Left Property of Canvas For right to left marquee: use Right Property of Canvas For upward marquee: use Bottom Property of Canvas For Downward marquee: use Top Property of Canvas Or <textblock grid.row="2" fontsize="22" name="txtScrolling"> <textblock.rendertransform> <translatetransform x:name="translate" xmlns:x="#unknown"> <textblock.triggers> <eventtrigger routedevent="FrameworkElement.Loaded"> <beginstoryboard> <storyboard repeatbehavior="Forever"> <doubleanimation> From="1200" To="-1200" Storyboard.TargetName="translate" Storyboard.TargetProperty="X" Duration="0 : 0 :9" /> This is the Text to Scroll

更多推荐

在WPF中自动从左到右移动标签

本文发布于:2023-11-06 17:13:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564295.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标签   WPF   左到右

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!