АНИМАЦИЯ выезжающего окна в XAML, C#, WPF.

415
23 сентября 2018, 19:40

помогите с анимацией. У меня при нажатии на кнопку выдвигается окно. Все бы хорошо но при выдвижении кнопка пропадает под окном, которое выдвигалось. Как сделать так что бы она не пропадала. Вот код XAML:

<Window x:Class="Audio_Player.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"
    xmlns:local="clr-namespace:Audio_Player"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    mc:Ignorable="d"
    Title="APFK" Height="450" Width="300" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Visibility="Visible" WindowStyle="None" AllowsTransparency="True" Background="Transparent">
<Window.Resources>
    <Storyboard x:Key="OpenMenu">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="43.5"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle1">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-43.5"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectangle2">
            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="GridMenu">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="300"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Key="CloseMenu">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle">
            <EasingDoubleKeyFrame KeyTime="0" Value="43.5"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle1">
            <EasingDoubleKeyFrame KeyTime="0" Value="-43.5"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="rectangle2">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="GridMenu">
            <EasingDoubleKeyFrame KeyTime="0" Value="300"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</Window.Resources>
<Grid Background="#FF7C9AFF">
    <StackPanel Orientation="Vertical" VerticalAlignment="Top" MouseDown="Panel_MouseDown" Height="450">
        <Grid Background="#FF107CFF" Height="33" VerticalAlignment="Top">
            <Button x:Name="ButtonEx" Height="28" Width="34" Padding="0" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#467AF3" HorizontalAlignment="Right" Margin="3 " Click="ButtonEx_Click">
                <!-- <materialDesign:PackIcon Kind="CloseOutline" Height="28" Width="30" />-->
                <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Rectangle Width="25" Height="4" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
                        <Rectangle.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform Angle="43"/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Rectangle.RenderTransform>
                    </Rectangle>
                    <Rectangle Width="25" Height="4" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="1,0,-1,0" RenderTransformOrigin="0.5,0.5">
                        <Rectangle.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform Angle="-43"/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Rectangle.RenderTransform>
                    </Rectangle>
                </Grid>
            </Button>
        </Grid>
        <Grid Height="185" Background="White">
            <!-- здесь кнопки плей, вперед, назад, повтор той же песни, рандомный порядок музыки, громкость -->
        </Grid>
        <Ellipse Height="130" Width="130" Margin="75,-175,75,150" Fill="White" Stroke="#FFFFD06D" StrokeDashCap="Round" StrokeThickness="10" >
        </Ellipse>
    </StackPanel>
    <Grid>
        <Button Height="24" Width="33" Padding="0" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#467AF3" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3 " Click="ButtonMenu_Click">
            <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                <Rectangle x:Name="rectangle" Width="25" Height="4" Margin="0 0 0 0" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Top" RenderTransformOrigin="0.11, 0.51">
                    <Rectangle.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle x:Name="rectangle1" Width="25" Height="4" Margin="0 14 0 0 " Fill="White" HorizontalAlignment="Center" VerticalAlignment="Top" RenderTransformOrigin="0.11, 0.51">
                    <Rectangle.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle x:Name="rectangle2" Width="25" Height="4" Margin="0 7 0 0" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Top"/>
                <!--<materialDesign:PackIcon Kind="ViewHeadline" Height="24" Width="30" />-->
            </Grid>
        </Button>
        <Grid x:Name="GridMenu" Height="450" Width="0"  HorizontalAlignment="Left" Background="#FF7C9AFF">
            <StackPanel>
                <Grid Height="100" Background="white"/>
            </StackPanel>
        </Grid>
    </Grid>
</Grid>

Вот код c#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Audio_Player
{
  /// <summary>
  /// Логика взаимодействия для MainWindow.xaml
  /// </summary>
 public partial class MainWindow : Window
 {
    bool StateClosed = true;
    public MainWindow()
    {
        InitializeComponent();
    }
    private void ButtonEx_Click(object sender, RoutedEventArgs e)
    {
        Application.Current.Shutdown();
    }
    private void Panel_MouseDown(object sender, MouseButtonEventArgs e)
    {
        DragMove();
    }
    private void ButtonMenu_Click(object sender, RoutedEventArgs e)
    {

        if (StateClosed)
        {
            Storyboard sb = this.FindResource("OpenMenu") as Storyboard;
            sb.Begin();
        }
        else
        {
            Storyboard sb = this.FindResource("CloseMenu") as Storyboard;
            sb.Begin();
        }
        StateClosed = !StateClosed;


    }
}

}

READ ALSO
Session на разных под доменах

Session на разных под доменах

У меня в точности идентичный вопрос как тут How can I share a session across multiple subdomains in ASPNET? только мне не помогла строка:

180
Подключение файла cs из вложенной папки в проект

Подключение файла cs из вложенной папки в проект

Как подключить файл cs из вложенной папки в проектеПри подключении имеющегося элемента в проект файл появляется в корне проекта, а нужно подключить...

213
Где реализован IEnumerator?

Где реализован IEnumerator?

У меня появился вопрос, который не дает мне покоя вот уже несколько часовДля того, чтобы использовать foreach для кастомной коллекции, нужно...

223