千家信息网

C# 中怎么利用WPF自定义菜单切换动画

发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,本篇文章给大家分享的是有关C# 中怎么利用WPF自定义菜单切换动画,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。添加Nuget库使用 .
千家信息网最后更新 2024年09月22日C# 中怎么利用WPF自定义菜单切换动画

本篇文章给大家分享的是有关C# 中怎么利用WPF自定义菜单切换动画,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

添加Nuget库

使用 .Net Core 3.1 创建名为"CustomMenu"的WPF解决方案,添加两个Nuget库:MaterialDesignThemes和MaterialDesignColors。

MaterialDesign控件库

3.2 工程结构

只修改了App.xaml(添加MD控件样式)和MainWindow.xaml(主窗口实现效果)。

3.3 App.xaml引入MD控件样式

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CustomMenu"
StartupUri="MainWindow.xaml">



















3.4 主窗体 MainWindow.xaml

添加菜单、设置菜单项切换动画等:

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
xmlns:local="clr-namespace:CustomMenu"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
Title="MainWindow" Height="600" Width="1080" Background="#FF292929" ResizeMode="NoResize" WindowStyle="None"
WindowStartupLocation="CenterScreen">



Storyboard.TargetName="ellipse">









Storyboard.TargetName="ellipse">









Storyboard.TargetName="ellipse">















































RenderTransformOrigin="0.5 0.5">












以上就是C# 中怎么利用WPF自定义菜单切换动画,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。

0