简体   繁体   English

如何在 visual studio 上使用 WPF 框架制作扩展表单?

[英]How to make an expanding form using WPF framework on visual studio?

So on the opening of my application I want it to go from a tiny little box to its normal size.所以在打开我的应用程序时,我希望它从一个小盒子变成 go 到它的正常大小。

Here is an example video: https://youtu.be/HIhuGGgRSuc这是一个示例视频: https://youtu.be/HIhuGGgRSuc

I'm new to wpf mainly the xaml part so im kinda stuck on what to do.我是 wpf 的新手,主要是 xaml 部分,所以我有点不知道该怎么做。

I have made a small sample using the story board.我使用故事板制作了一个小样本。 In XAML I did the following:在 XAML 中,我做了以下操作:

  1. Named my MainWindow and Grid.命名我的 MainWindow 和 Grid。

  2. Set the following properties on my Main Window:在我的 Main Window 上设置以下属性:

    • Width and Height = Auto宽度和高度 = 自动

    • SizeToContent = WidthAndHeight SizeToContent = 宽度和高度

    • WindowStartUpLocation = CenterScreen WindowStartUpLocation = CenterScreen

    • WindowStyle = None窗口样式 = 无

  3. Set the animation codes under Windows.Resources.在 Windows.Resources 下设置 animation 代码。

Here are the XAML codes:以下是 XAML 代码:

<Window x:Name="MainWin" x:Class="Window_Animation_Sample.MainWindow"
    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"
    mc:Ignorable="d"
    Title="MainWindow" Width="Auto" Height="Auto" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen" WindowStyle="None">
<Window.Resources>
    <Storyboard x:Key="ExpandingAnimation">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ExpandingGrid" Storyboard.TargetProperty="(FrameworkElement.Height)">
            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"></EasingDoubleKeyFrame>
            <EasingDoubleKeyFrame KeyTime="00:00:01" Value="0"></EasingDoubleKeyFrame>
            <EasingDoubleKeyFrame KeyTime="00:00:05" Value="400"></EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</Window.Resources>

<Grid x:Name="ExpandingGrid">
    <MediaElement Width="800" Height="400"/>
</Grid>

Here are the C# codes:以下是 C# 代码:

using System.Windows;
using System.Windows.Media.Animation;

namespace Window_Animation_Sample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Storyboard ExpandingAnime = (Storyboard)TryFindResource("ExpandingAnimation");
            ExpandingAnime.Begin();
        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Visual Studio 2010框架4.0中使用扩展WPF工具包2.0 - using Extended WPF toolkit 2.0 in visual studio 2010 framework 4.0 如何在 Visual Studio 中将 Windows.Forms 框架添加到 WPF 项目 - How to add Windows.Forms framework to WPF project in Visual Studio 如何将WPF中的默认Mainwindows窗体更改为WIndow1 c#。我正在使用Visual Studio 2012 - How to change Default Mainwindows form in wpf to WIndow1 c#.I am using Visual Studio 2012 如何制作清单 <Object> 在Visual Studio中使用WPF时,变量是否出现在DataBinding UI中? - How to make List<Object> variable appear in DataBinding UI when using WPF in Visual Studio? 当我将 Metro 框架用于 c# 时,如何导航到 Visual Studio 中的下一个表单? - How can I navigate to next form in Visual studio when I'm using metro framework for c#? 当我使用Designer向表单添加新控件时,如何阻止visual studio更改WPF表单中控件的属性? - How to stop visual studio from changing properties of controls in WPF form when I add a new control to form using Designer? 如何在 30 分钟后关闭 windows 表单? | 视觉工作室 C# Windows Forms App.Net 框架 - How do I make a windows form close after 30 minutes? | Visual Studio C# Windows Forms App .Net Framework 如何在Visual Studio中制作类似属性窗口的表格? - How to make a form like properties window in visual studio? 使用C#,WPF,实体框架和Visual Studio 2012不会在数据库中更新数据 - Data is not updated in database, using C#,WPF, Entity framework and Visual studio 2012 如何避免Visual Studio自动扩展所有自定义控件 - How to avoid Visual Studio auto expanding all custom controls
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM