WPF 按键图标转动效果示例

html 复制代码
        <Storyboard x:Key="IconStoryboard">
            <DoubleAnimation
                                Storyboard.TargetName="PackIconFileIcon"
                                Storyboard.TargetProperty="(iconPacks:PackIconFileIcons.RotationAngle)"
                                From="0"
                                To="360"
                                Duration="0:0:0.3"
                               />
        </Storyboard>

        <ToggleButton x:Name="toggleBtn" VerticalAlignment="Top" Width="30" Height="30" Margin="0,0,0,0">
            <iconPacks:PackIconFileIcons x:Name="PackIconFileIcon" Kind="Actionscript"  />
        </ToggleButton>
csharp 复制代码
		private void toggleBtn_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
			_pressedPosition2 = e.GetPosition(this);
		}

		private void toggleBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
		{
			if (Mouse.LeftButton == MouseButtonState.Released && _pressedPosition2 == e.GetPosition(this))
			{
				if (toggleBtn.IsChecked == true)
				{
					//ItemsCtrl.Visibility = Visibility.Visible;
					var expandStoryboard = (Storyboard)FindResource("ExpandStoryboard");
					expandStoryboard.Begin();

					var IconStoryboard = (Storyboard)FindResource("IconStoryboard");
					IconStoryboard.Begin();
				}
				else
				{
					var collapseStoryboard = (Storyboard)FindResource("CollapseStoryboard");
					collapseStoryboard.Begin();

					var IconStoryboard = (Storyboard)FindResource("IconStoryboard");
					IconStoryboard.Begin();
					//ItemsCtrl.Visibility = Visibility.Hidden;
				}
			}
		}
相关推荐
samble6 小时前
从零搭建半导体设备上位机(十二):参数设置页,表单校验、范围校验与配方联动
wpf·数据校验·validationrule
ShineWinsu8 小时前
对于Qt:QFormLayout常见属性以及方法的解析
开发语言·c++·qt·面试·客户端·表单·qformlayout
利威尔xu12 小时前
Go channel 关闭 3 个 panic:向已关闭 channel 发送,服务当场崩溃
开发语言·后端·golang·并发编程·channel
山楂树の13 小时前
Java BigDecimal笔记
java·开发语言
Java展博16 小时前
[Go 后端转场] 从 try-catch 到 if err != nil:写惯 Java 的人第一次上手最别扭的 4 件事
java·开发语言·golang
SEO_juper16 小时前
Node.js 全站 SEO 体检报告生成器:一次查完标题、描述、canonical、H1、图片
开发语言·前端·node.js·html·bash
风落青芜17 小时前
数据结构:堆的概念与实现
c语言·开发语言·数据结构·算法
H H.20 小时前
Java企业级开发:从框架到工程化实战
java·开发语言·经验分享·其他·课程设计
吃我一窝jio1 天前
Python与Go线程模型深度对比
java·开发语言·python
eggwyw1 天前
C++ union 的一种妙用法
开发语言·c++