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

C# Avalonia 16- Animation- RotateButton

RotateButton.axaml代码

<Window xmlns="https://github.com/avaloniaui"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"Width="300" Height="300"x:Class="AvaloniaUI.RotateButton"Title="RotateButton"><Window.Styles><!-- 针对所有 Button 的基础样式 --><Style Selector="Button"><Setter Property="HorizontalAlignment" Value="Center"/><Setter Property="RenderTransformOrigin" Value="50%,50%"/><Setter Property="Padding" Value="20,15"/><Setter Property="Margin" Value="2"/><Setter Property="RenderTransform"><Setter.Value><RotateTransform Angle="0"/></Setter.Value></Setter><Style Selector="^:pointerover"><Style.Animations><Animation Duration="0:0:2" IterationCount="INFINITE" FillMode="None"><KeyFrame Cue="0%"><Setter Property="RotateTransform.Angle" Value="0"/></KeyFrame><KeyFrame Cue="100%"><Setter Property="RotateTransform.Angle" Value="360"/></KeyFrame></Animation></Style.Animations></Style><Style Selector="^:not(:pointerover)"><Style.Animations><Animation Duration="0:0:0.18" FillMode="Forward"><KeyFrame Cue="100%"><Setter Property="RotateTransform.Angle" Value="0"/></KeyFrame></Animation></Style.Animations></Style></Style></Window.Styles><StackPanel Margin="5" Button.Click="cmd_Clicked"><Button>One</Button><Button>Two</Button><Button>Three</Button><Button>Four</Button><TextBlock Name="lbl" Margin="5"/></StackPanel>
</Window>

RotateButton.axaml.cs代码

using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Shares.Avalonia;namespace AvaloniaUI;public partial class RotateButton : Window
{public RotateButton(){InitializeComponent();}private void cmd_Clicked(object? sender, RoutedEventArgs e){lbl.Text = "You clicked: " + ((Button)e.Source!).Content;}
}

运行效果

image

 

http://www.zskr.cn/news/16435.html

相关文章:

  • 详细介绍:python第31天打卡
  • 如何采用插件和子主题添加WordPress自定义CSS(附:常见错误)
  • 02020502 EF Core高级02-IQuerable会延迟执行、分部和动态构建IQuerable、IQuerable的复用
  • 在 PyCharm 中,环境:bert_env , 执行 import wandb 报错。但是,在CMD窗口,环境:bert_env , 执行 import wandb 正常。
  • Linux_T(Sticky Bit)粘滞位详解 - 详解
  • Valley靶机渗透实战:从凭证复用到Python库劫持
  • 深入解析:IP Search Performance Tests dat/db/xdb/mmdb 结构性能差异对比
  • 10.05模拟赛反思
  • 如何快速搭建spring-boot工程 - murphy
  • 做题记录 #1
  • 深度学习优化器算法巧思速览
  • 在Windows下使用lucky实现TLS/SSL证书自动化
  • CF700E
  • 价值弥漫:“AI元人文”的场域革命与共生之路
  • k8s之pod概念
  • 鸿蒙版Taro 搭建开发环境 - 教程
  • CF 1055 Div.1+Div.2
  • 2026 NOI 做题记录(五)
  • “齐俊杰投资智能体”更新完了9月份的资料
  • docker 离线安装
  • minio 离线安装
  • 银行同业存单产品的筛选方法
  • deepseek 私有部署文档
  • MySQL运维及开发规范
  • 异步读写mysql依赖pymysql (asyncio/ aiomysql)
  • Linux发行版切换技术全解析
  • 完整教程:高效Excel数据净化工具:一键清除不可见字符与格式残留
  • 手把手教你用 Docker 部署 Redis
  • 长租公寓的生存越来越难了 - 智慧园区
  • Spring Boot中保存前端上传的图片 - 教程