WPF如何实现上下滚动字幕效果

  介绍

这篇文章主要介绍了WPF如何实现上下滚动字幕效果,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获、下面让小编带着大家一起了解一下。

XAML代码:

& lt;当地:WorkSpaceContent  x:类=癝unCreate.CombatPlatform.Client.NoticeMarquee"   xmlns=才能“http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:才能x=癶ttp://schemas.microsoft.com/winfx/2006/xaml"   xmlns:才能mc=? http://schemas.openxmlformats.org/markup-compatibility/2006",,   xmlns:才能d=癶ttp://schemas.microsoft.com/expression/blend/2008",,   xmlns:当地=安拍躢lr-namespace: SunCreate.CombatPlatform.Client;装配=SunCreate.CombatPlatform.Client"   主持人:可忽略的=安拍躣",   d:才能DesignHeight=?5”, d: DesignWidth=?00“,加载=癢orkSpaceContent_Loaded", MouseEnter=癢orkSpaceContent_MouseEnter", MouseLeave=癢orkSpaceContent_MouseLeave"比;   ,& lt;地方:WorkSpaceContent.Resources>   ,& lt; ControlTemplate  x:关键=癰tnTemplate", TargetType=癇utton"比;   & lt;才能TextBlock  Name=皌xt",利润率=?5,0,5,0“,文本=皗TemplateBinding 内容}“,字形大??2”,光标=癏and",工具提示=皗TemplateBinding 提示}“,前景=? fff", VerticalAlignment=癈enter"祝辞& lt;/TextBlock>   & lt;才能ControlTemplate.Triggers>   & lt;才能Trigger 财产=癐sMouseOver", https://www.yisu.com/zixun/Value=" true ">               故事板      故事板      <网格背景=" # 00 a6da ">                     <身高=" 25 ">               <按钮名称=" btn1 "高度=?5”点击=癰tn_Click”模板=" {StaticResource btnTemplate} ">   <按钮名称="这里"高度=?5”点击=癰tn_Click”模板=" {StaticResource btnTemplate} ">   <按钮名称=" btn3 "高度=?5”点击=癰tn_Click”模板=" {StaticResource btnTemplate} ">               

后台代码:

using  SunCreate.CombatPlatform.Domain;   using 系统;   using  System.Collections.Generic;   using 来;   using 包含;   using  System.Threading;   using  System.Timers;   using  System.Windows;   using  System.Windows.Controls;   using  System.Windows.Data;   using  System.Windows.Documents;   using  System.Windows.Input;   using  System.Windows.Media;   using  System.Windows.Media.Animation;   using  System.Windows.Media.Imaging;   using  System.Windows.Navigation;   using  System.Windows.Shapes;      namespace  SunCreate.CombatPlatform.Client   {   ,///& lt; summary>   ,///公告滚动显示   ,///& lt;/summary>   ,public  partial  class  NoticeMarquee : WorkSpaceContent   ,{   ,private  System.Timers.Timer  _timer;   ,private  List _data;   ,private  int  _index;   ,private  Storyboard  _storyboard;      ,public  NoticeMarquee ()   ,{   InitializeComponent才能();   ,}      ,private  void  WorkSpaceContent_Loaded (object ,发送方,RoutedEventArgs  e)   ,{   if 才能;(_timer ==, null)   {才能   _storyboard 才能=,(故事板)this.FindResource (“storyboard");      System.Threading.Tasks.Task.Factory.StartNew才能((),=比;   {才能   ,,while (真正的)   ,,{   ,,int  total =, 0;   ,,_data =, HI.Get

WPF如何实现上下滚动字幕效果