当前位置: 首页 > 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.rkmt.cn/news/19227.html

相关文章:

  • PVE8.x仅克隆虚拟机配置
  • SQL常用语句分类及示例
  • Electron38-Vue3OS客户端OS系统|vite7+electron38+arco桌面os后台管理
  • 视频拍摄技巧 - 希区柯克变焦/滑动变焦 All In One
  • 记录:git
  • 2025年10月门窗十大品牌最新推荐榜单,十大品牌测评排名与选择指南
  • CF60E Mushroom Gnomes
  • LCPC12E - Johnnys Empire 题解
  • 美国能源部《生成式人工智能参考指南》解读
  • win10系统访问smb服务时提示密码错误
  • 《小说课》读书笔记
  • 鸡哥单人防守爽图7.0通关.
  • AtCoder Beginner Contest 427 ABCDEF 题目解析
  • zju博士资格考试考前复习(微分方程方向)ode 部分
  • 测试一下博客功能
  • NOIP 2024
  • ffplay数据结构解析
  • FileX和ThreadX精简版
  • ue4素材场景 - MKT
  • 阅读《构建之法》的思考与问题
  • 2025年9月22日优雅草蜻蜓I通讯水银版4.1.9版本正式发布-完成所有服务升级版本重构升级-修复大量漏洞-优化启动步骤-卓伊凡|bigniu|麻子|贝贝| - 指南
  • count down 84 days - 详解
  • AWS自然语言处理技术实战指南
  • 10.12~10.18随笔
  • 面向对象的题目
  • [HZOI] CSP-S模拟29
  • 二三阶行列式
  • CHAR与VARCHAR深度解析:MySQL字符类型选择指南与性能对比
  • vivo霸榜背后:以技术打赢用户保卫战
  • securityCTF 2025 pwn方向题解