尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

C# Avalonia 16- Animation- ExpandElement

C# Avalonia 16- Animation- ExpandElement
📅 发布时间:2026/6/20 17:40:49
C# Avalonia 16- Animation- ExpandElement

置顶的 C# Avalonia配置 已经更新

ExpandElement.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="500" Height="400"xmlns:local="using:AvaloniaUI"x:Class="AvaloniaUI.ExpandElement"x:DataType="local:ExpandElementViewModel"Title="ExpandElement"><Window.Styles><Style Selector="Border#element"><Style.Animations><!-- https://docs.avaloniaui.net/docs/reference/controls/datagrid/ --><Animation Duration="0:0:2.5" FillMode="Forward"><!-- 起始 --><KeyFrame Cue="0%"><Setter Property="Opacity" Value="0.2"/><Setter Property="ScaleTransform.ScaleX" Value="0"/><Setter Property="ScaleTransform.ScaleY" Value="0"/><Setter Property="RotateTransform.Angle" Value="70"/></KeyFrame><!-- 展开动画 --><KeyFrame Cue="80%"><Setter Property="Opacity" Value="1"/><Setter Property="ScaleTransform.ScaleX" Value="1"/><Setter Property="ScaleTransform.ScaleY" Value="1"/><Setter Property="RotateTransform.Angle" Value="0"/></KeyFrame><!-- 弹性缩放 --><KeyFrame Cue="90%"><Setter Property="ScaleTransform.ScaleX" Value="0.98"/><Setter Property="ScaleTransform.ScaleY" Value="0.98"/></KeyFrame><KeyFrame Cue="100%"><Setter Property="ScaleTransform.ScaleX" Value="1"/><Setter Property="ScaleTransform.ScaleY" Value="1"/></KeyFrame></Animation></Style.Animations></Style></Window.Styles><Grid><Border Name="element"Margin="3"Background="LightGoldenrodYellow"BorderBrush="DarkBlue"BorderThickness="2"CornerRadius="5"Opacity="0.2"><Border.RenderTransform><TransformGroup><ScaleTransform/><RotateTransform/></TransformGroup></Border.RenderTransform><ScrollViewer><StackPanel Margin="10"><TextBlock Text="The foof feature is indispensable. You can configure the foof feature using the Foof Options dialog box."TextWrapping="Wrap" /><Button Content="Open Foof Options"HorizontalAlignment="Left"Margin="0,5,0,15" /><TextBlock Text="Largest Cities in the Year 100"FontSize="20"FontWeight="Bold"Margin="0,10" /><DataGrid CanUserSortColumns="False"AutoGenerateColumns="False"ItemsSource="{Binding Cities}"><DataGrid.ColumnHeaderTheme><ControlTheme TargetType="DataGridColumnHeader"><Setter Property="Background" Value="#444" /><Setter Property="FontSize" Value="15"/><Setter Property="Foreground" Value="White" /><Setter Property="BorderThickness" Value="0"/><Setter Property="BorderBrush" Value="Transparent"/><Setter Property="FontWeight" Value="Bold" /><Setter Property="HorizontalContentAlignment" Value="Center"/><Setter Property="VerticalContentAlignment" Value="Center"/></ControlTheme></DataGrid.ColumnHeaderTheme><DataGrid.Columns><DataGridTextColumn Header="Rank" Binding="{Binding Rank}" /><DataGridTextColumn Header="Name" Binding="{Binding Name}" /><DataGridTextColumn Header="Population" Binding="{Binding Population}" /></DataGrid.Columns></DataGrid></StackPanel></ScrollViewer></Border>        </Grid>
</Window>

ExpandElement.axaml.cs代码

using Avalonia;
using Avalonia.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;namespace AvaloniaUI;
public class City
{public int Rank { get; set; }public string? Name { get; set; }public string? Population { get; set; }
}public class ExpandElementViewModel : ObservableObject
{public ObservableCollection<City> Cities { get; set; } = new(){new City { Rank = 1, Name = "Rome", Population = "450,000" },new City { Rank = 2, Name = "Luoyang (Honan), China", Population = "420,000" },new City { Rank = 3, Name = "Seleucia (on the Tigris), Iraq", Population = "250,000" },new City { Rank = 4, Name = "Alexandria, Egypt", Population = "250,000" },new City { Rank = 5, Name = "Antioch, Turkey", Population = "150,000" },new City { Rank = 6, Name = "Anuradhapura, Sri Lanka", Population = "130,000" },new City { Rank = 7, Name = "Peshawar, Pakistan", Population = "120,000" },new City { Rank = 8, Name = "Carthage, Tunisia", Population = "100,000" },new City { Rank = 9, Name = "Suzhou, China", Population = "n/a" },new City { Rank = 10, Name = "Smyrna, Turkey", Population = "90,000" }};
}
public partial class ExpandElement : Window
{public ExpandElement(){InitializeComponent();this.DataContext = new ExpandElementViewModel();}
}

运行效果

image

 

相关新闻

  • PVE8.x仅克隆虚拟机配置
  • SQL常用语句分类及示例
  • Electron38-Vue3OS客户端OS系统|vite7+electron38+arco桌面os后台管理

最新新闻

  • Ubuntu 14.04下WordPress XML-RPC四层防御实战
  • M2-PALE:融合过程挖掘与LLM的可解释混合智能体框架
  • Quanto量化实战:让Transformer在CPU/边缘设备高效运行
  • 基于流匹配与复值自编码器的脑肿瘤MRI生成式数据增强实战
  • 【技术干货】AI应用构建器实战:用大模型规划并生成创作者赞助管理后台
  • Ubuntu 20.04 安装 TensorFlow 的三大兼容性陷阱与生产级解决方案

日新闻

  • Visual C++运行库修复终极指南:5分钟快速解决Windows软件启动错误
  • 手把手教你构建统计局地区经济数据爬虫:从环境搭建到数据持久化全指南
  • 2026多Agent深度解析:用AI团队替代单一模型,四种架构实战落地

周新闻

  • Visual C++运行库修复终极指南:5分钟快速解决Windows软件启动错误
  • 手把手教你构建统计局地区经济数据爬虫:从环境搭建到数据持久化全指南
  • 2026多Agent深度解析:用AI团队替代单一模型,四种架构实战落地

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号