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

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

 

http://www.hskmm.com/?act=detail&tid=29055

相关文章:

  • DshanPI-A1 RK3576 armbian远程桌面
  • Docker安装MQTT
  • Ubuntu Linux双网卡实现在校园网环境下的网络共享
  • PVE8.x仅克隆虚拟机配置
  • 常用的sql语句
  • SQL常用语句分类及示例
  • 台式机主板上的电池要更换啦
  • 微信小程序 app.js中onLaunch中方法执行完毕后再执行index首页数据请求
  • 轻量服务器Lighthouse + 1Panel 部署.NET 8 Web应用
  • bash alias 多引号问题
  • 关于近期调研各类游戏开发引擎的一些感想
  • Electron38-Vue3OS客户端OS系统|vite7+electron38+arco桌面os后台管理
  • 终于在vim中用上了molokai的炫酷色彩配置了(゚∀゚)
  • 我是如何在Vim8.1中安装好的NERDTree插件的
  • Kafka监控工具 EFAK-AI 介绍
  • 视频拍摄技巧 - 希区柯克变焦/滑动变焦 All In One
  • 信息化说课-教学设计(6)
  • 记录:git
  • 实验1 现代C++编程初体验
  • 10.11总结
  • 2025年10月门窗十大品牌最新推荐榜单,十大品牌测评排名与选择指南
  • CF60E Mushroom Gnomes
  • CF691E Xor-sequences
  • LCPC12E - Johnnys Empire 题解
  • 中微笔记-cp.1 技术
  • P1896 [SCOI2005] 互不侵犯小总结
  • 美国能源部《生成式人工智能参考指南》解读
  • 分析InfluxDB中读取时CPU飙升
  • win10系统访问smb服务时提示密码错误
  • 《小说课》读书笔记