当前位置: 首页 > 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.hskmm.com/?act=detail&tid=25377

相关文章:

  • 2025 十一集训
  • 汇编实验3
  • 20251005 模拟测 总结
  • 基于Python+Vue开发的体育用品商城管理系统源码+运行步骤
  • 完整教程:Microsoft Word使用技巧分享(本科毕业论文版)
  • (转)The Ten Commandments of Digital Cotrol(Part1)
  • ctf逆向常见算法----base64
  • 02020409 EF Core基础09-一对一、多对多、EF Core基于关系的复杂查询
  • 02020503 EF Core高级03-分页查询、IQuerable底层的实现形式、DataReader、DataTable、EF Core中的异步方法
  • 02020502 EF Core高级02-IQuerable会延迟执行、分部和动态构建IQuerable、IQuerable的复用
  • 在 PyCharm 中,环境:bert_env , 执行 import wandb 报错。但是,在CMD窗口,环境:bert_env , 执行 import wandb 正常。
  • Linux_T(Sticky Bit)粘滞位详解 - 详解
  • P2831 [NOIP 2016 提高组] 愤怒的小鸟 题解
  • 库存中心(三层库存模型)
  • Valley靶机渗透实战:从凭证复用到Python库劫持
  • 10.05模拟赛反思
  • MariaDB收购SkySQL增强AI与无服务器能力
  • 单片机寄存器的四种主要类型! - 实践
  • TDengine 高级特性——读缓存
  • 非合作博弈之软性均衡:东方智慧与西方理论的融合框架
  • 如何快速搭建spring-boot工程 - murphy
  • Ai元人文:东谈西论——非合作博弈之软性均衡
  • 反向传播与梯度下降:神经网络如何真正学会分类
  • Spring Cloud Alibaba微服务开发
  • OI 各种东西的板子
  • 价值弥漫:AI元人文的场域革命与共生之路
  • 做题记录 #1
  • 阿爸阿爸
  • 深度学习优化器算法巧思速览
  • 完整教程:LangChain完全指南:从入门到精通,打造AI应用开发新范式