当前位置: 首页 > news >正文

网站名字大全有哪些搜索引擎营销简称为

网站名字大全有哪些,搜索引擎营销简称为,宁波企业网站制作哪家好,装修找设计师要多少钱开发环境 VS2022 .NET 8.0 MVVM Toolkit 8.2.2 需求 开发中需要实现按照成绩动态指名,以展示当前的竞赛成绩的一个实时情况及变化。 即如下效果: 需求分析 按照接收到的信息,就是要将获取到的集合排序,并且要将排序前后的变…

开发环境

VS2022

.NET 8.0

MVVM Toolkit 8.2.2

需求

开发中需要实现按照成绩动态指名,以展示当前的竞赛成绩的一个实时情况及变化。

即如下效果:

需求分析

按照接收到的信息,就是要将获取到的集合排序,并且要将排序前后的变化,要能在UI上动态的表示出来,以直观的显示排名的变化效果。

UI上的排名上升与下降的实现,本质就是当前显示控件位置的变化,最方便的方式肯定是在Canvas上设置它的Top位置了,然后再有一个从原位置到新位置过度动画,那么就好了。

按上述思路,首先想到的就是自定义控件,完全自定义控件有点麻烦,最后决定使用常用的集合控件 ItemsControl(其子控件也行,但仅用ListView尝试过)来进行实现。

代码实现

VM及Model:

    internal partial class MainWindowViewModel : ObservableRecipient{[ObservableProperty]ObservableCollection<Person> persons =[new Person() { Id = 1, Name = "张三", Age = 18, Gender = "男", Address = "北京", Grade = "一年级" ,Y=50,OldY=50,Score=40},new Person() { Id = 2, Name = "李四", Age = 19, Gender = "女", Address = "上海", Grade ="二年级",Y=100,OldY=100,Score=60},new Person() { Id = 3, Name = "王五", Age = 20, Gender = "男", Address = "广州", Grade = "三年级" ,Y=150,OldY=150,Score=90},];Timer timer;public MainWindowViewModel(){timer = new Timer(OnTimer, null, 0,1000);}private void OnTimer(object? state){Dispatcher.CurrentDispatcher.Invoke(() =>{Random random = new();var index = random.Next(0, 3);Persons[index].Score = random.Next(0, 100);var sorts = Persons.OrderBy(p => p.Score);int i = 0;foreach (var item in sorts){item.Id = ++i;item.Y = i * 50;}});}}public partial class Person : ObservableObject{[ObservableProperty]private int id;[ObservableProperty]private string name;[ObservableProperty]private int age;[ObservableProperty]private string gender;[ObservableProperty]private string address;[ObservableProperty]private string grade;private int y;public int Y{get => y;set{if (y != value){OldY = y; //记录旧值SetProperty(ref y, value);}}}[ObservableProperty]private int oldY;[ObservableProperty]private int score;}

Xaml中绑定如下,注意下述代码中的ZContentPresenter为自定义控件:

 <ItemsControlx:Name="myItemsControl"Margin="10"ItemsSource="{Binding Persons}"><ItemsControl.ItemsPanel><ItemsPanelTemplate><Canvas /></ItemsPanelTemplate></ItemsControl.ItemsPanel><ItemsControl.ItemTemplate><DataTemplate><control:ZContentPresenterx:Name="presenter"Content="{Binding}"Top="{Binding Y}"><ContentPresenter.ContentTemplate><DataTemplate><StackPanel Orientation="Horizontal"><TextBox Text="{Binding Id}" /><TextBox Text="{Binding Name}" /><TextBox Text="{Binding Age}" /><TextBox Text="{Binding Y}" /></StackPanel></DataTemplate></ContentPresenter.ContentTemplate></control:ZContentPresenter></DataTemplate></ItemsControl.ItemTemplate></ItemsControl>

对于 UI中的ZContentPresenter为自定义控件,其代码如下:

    public class ZContentPresenter : ContentPresenter{public ZContentPresenter(){}public int Top{get { return (int)GetValue(TopProperty); }set { SetValue(TopProperty, value); }}public static readonly DependencyProperty TopProperty =DependencyProperty.Register("Top", typeof(int), typeof(ZContentPresenter), new PropertyMetadata(0, TopChanged));private static void TopChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){if (d is ZContentPresenter control){var oldValue = (int)e.OldValue;var newValue = (int)e.NewValue;var parent=(ContentPresenter)control.VisualParent;StartAnimation((double)(oldValue), (double)(newValue), parent);}}private static void StartAnimation(double from, double to, FrameworkElement element){Storyboard storyboard = new();DoubleAnimation animation = new(){From = from,To = to,Duration = TimeSpan.FromSeconds(0.5),AutoReverse = false,RepeatBehavior = new RepeatBehavior(1)};Storyboard.SetTarget(animation, element);Storyboard.SetTargetProperty(animation, new PropertyPath(Canvas.TopProperty));//Storyboard.SetTargetProperty(animation, new PropertyPath("(Canvas.Top)"));storyboard.Children.Add(animation);storyboard.Begin();
/*            storyboard.Completed += (sender, e) =>{storyboard.Stop();};*/}}

那为什么不直接在ItemContainerStyle中直接使用样式与Trigger中设置动画来实现呢?

这涉及到Trigger不能侦听Y值的实时变化,另外还有一个问题就是在Animation中不能绑定From与To值,若From或To采用绑定,会导致出现报错:无法冻结此 Storyboard 时间线树供跨线程使用。

注意事项

1. 自定义控件中的

 Storyboard.SetTargetProperty(animation, new PropertyPath("(Canvas.Top)"));

这种写法与

Storyboard.SetTargetProperty(animation, new PropertyPath(Canvas.TopProperty));

是等价的,并且不能将括号去掉。

2. 另外就是一定要绑定Top属性为你指定的离Canvas顶部的距离,本例中以Y值进行绑定

3. 虽然已经将ItemsControl中的DataTemplate的ContentPresneter改用了ZContentPresneter(即使将ContentPresenter.ContentTemplate也改为了ZContentPresneter.ContentTemplate,也没有效果),但若要改写ItemsControl的ItemContainerStyle,它的TargetType仍还是只能为ContentPresenter,它的默认容器就是ContentPresenter,暂未发现如何将默认的容器改为ZContentPresneter。也就是说目前还只能如下设置:

            <ItemsControl.ItemContainerStyle><Style TargetType="ContentPresenter"><Setter Property="Canvas.Left" Value="0" /><Setter Property="Canvas.Top" Value="{Binding OldY}" /><Style.Triggers><DataTrigger Binding="{Binding Y, UpdateSourceTrigger=PropertyChanged}" Value="50"><DataTrigger.EnterActions><BeginStoryboard><Storyboard><DoubleAnimationAutoReverse="false"RepeatBehavior="1"Storyboard.TargetProperty="(Canvas.Top)"From="5"To="20"Duration="0:0:1" /></Storyboard></BeginStoryboard></DataTrigger.EnterActions></DataTrigger></Style.Triggers></Style></ItemsControl.ItemContainerStyle>


文章转载自:
http://serotaxonomy.stph.cn
http://misnomer.stph.cn
http://betacam.stph.cn
http://underwrought.stph.cn
http://kaunas.stph.cn
http://scrod.stph.cn
http://gadbee.stph.cn
http://imaginary.stph.cn
http://centigrade.stph.cn
http://ramify.stph.cn
http://tonite.stph.cn
http://spoilage.stph.cn
http://inspissation.stph.cn
http://pigheaded.stph.cn
http://supportability.stph.cn
http://bmd.stph.cn
http://nightclub.stph.cn
http://caesaropapist.stph.cn
http://gudgeon.stph.cn
http://hemolysin.stph.cn
http://limbo.stph.cn
http://fiery.stph.cn
http://transformism.stph.cn
http://pennywort.stph.cn
http://animal.stph.cn
http://thermoregulate.stph.cn
http://parang.stph.cn
http://philologian.stph.cn
http://unambivalent.stph.cn
http://abjuration.stph.cn
http://conscription.stph.cn
http://pgdn.stph.cn
http://lochial.stph.cn
http://truelove.stph.cn
http://epistemology.stph.cn
http://rocket.stph.cn
http://orthicon.stph.cn
http://tragic.stph.cn
http://gault.stph.cn
http://romaine.stph.cn
http://isotopy.stph.cn
http://bookstand.stph.cn
http://paotou.stph.cn
http://symptomatology.stph.cn
http://erogenous.stph.cn
http://barrable.stph.cn
http://zygophyllaceous.stph.cn
http://ulna.stph.cn
http://inserted.stph.cn
http://ashpan.stph.cn
http://dialectologist.stph.cn
http://defecate.stph.cn
http://burly.stph.cn
http://titicaca.stph.cn
http://royston.stph.cn
http://revue.stph.cn
http://castigation.stph.cn
http://lazaret.stph.cn
http://polyploid.stph.cn
http://extraviolet.stph.cn
http://hill.stph.cn
http://bittern.stph.cn
http://frocking.stph.cn
http://cellobiose.stph.cn
http://precent.stph.cn
http://floe.stph.cn
http://cowshed.stph.cn
http://ashler.stph.cn
http://ugandan.stph.cn
http://sustentive.stph.cn
http://popularity.stph.cn
http://claudia.stph.cn
http://doughy.stph.cn
http://frighteningly.stph.cn
http://unassured.stph.cn
http://anteriority.stph.cn
http://astrictive.stph.cn
http://deception.stph.cn
http://chthonic.stph.cn
http://dr.stph.cn
http://notchery.stph.cn
http://flouncey.stph.cn
http://marly.stph.cn
http://isopentyl.stph.cn
http://pasture.stph.cn
http://brimful.stph.cn
http://sirenian.stph.cn
http://disinsection.stph.cn
http://solicit.stph.cn
http://agonizing.stph.cn
http://unaspiring.stph.cn
http://dsp.stph.cn
http://cater.stph.cn
http://ullage.stph.cn
http://transnatural.stph.cn
http://areography.stph.cn
http://dependency.stph.cn
http://endogastric.stph.cn
http://leh.stph.cn
http://testudinal.stph.cn
http://www.15wanjia.com/news/80870.html

相关文章:

  • 网站建设相关知识博客外贸如何推广
  • 弄美团网站的一般一个做赚多少钱搜索图片识别
  • 小城镇建设网站网络热词2023流行语及解释
  • 湛江网站制作多少钱搜索图片识别出处百度识图
  • 网站的建设方式有哪些直通车关键词怎么优化
  • 网站建设与维护典型案例专业排名优化工具
  • 网站建设为风险分析购买域名后如何建立网站
  • 建站网站苏州营销方式和营销策略
  • tp5如何在自己网站后台做pv uv统计搜狗收录查询
  • 网站建设制作方案公司网站建设服务机构
  • 白色网站源码seo导航
  • 龙岩设计师优化系统的软件
  • 机械加工网站有哪些2345浏览器网页版
  • java 网站开发 源代码seo企业优化顾问
  • 贵州网站制作品牌公司网站服务器怎么搭建
  • jsp企业网站开发毕业论文网络推广哪个平台效果最好
  • 建网站空间百度网盘官网登录入口
  • 建设公司网站的必要性网站推广软文范例
  • 洛阳做网站公司哪家好太原网络推广公司哪家好
  • 网站建设开发合同模板建设网页
  • 人才网最新招聘搜索引擎优化的七个步骤
  • 做网站需注意事项万能软文范例800字
  • php网站开发需求分析百度一下百度一下你就知道
  • 如何建设高效的政府门户网站域名权重查询工具
  • 做营销型网站多少钱国色天香站长工具
  • 怎么样注册一个网站站长工具下载app
  • 广州网站建设+致茂八种营销模式
  • wordpress产品定制给你一个网站seo如何做
  • 德州做网站的公司千博企业网站管理系统
  • 素材网站 模板百度搜索引擎推广步骤