2014-02-15 6 views
2

저는 스토리 보드를 설정하여 윈도우를 확대하고 축소했습니다. 블렌드 에디터에서는 이러한 기능이 제대로 작동하지만 실제로 실행될 때는 전혀 작동하지 않습니다.WPF 및 블렌드 : 크기 조정 윈도우가 작동하지 않습니다.

창은 세로로 같은 비율로 확대/축소됩니다.

이 수정 프로그램은 무엇입니까?

enter image description here

여기 내 XAML입니다.

<Window x:Name="window" x:Class="MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="32" Width="32" ResizeMode="NoResize" WindowStyle="None"> 
    <Window.Resources> 
     <Storyboard x:Key="GrowFrame"> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="window"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="32"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="256"> 
        <EasingDoubleKeyFrame.EasingFunction> 
         <BackEase EasingMode="EaseOut" Amplitude="0.25"/> 
        </EasingDoubleKeyFrame.EasingFunction> 
       </EasingDoubleKeyFrame> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="window"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="32"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="256"> 
        <EasingDoubleKeyFrame.EasingFunction> 
         <BackEase EasingMode="EaseOut" Amplitude="0.25"/> 
        </EasingDoubleKeyFrame.EasingFunction> 
       </EasingDoubleKeyFrame> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="window"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="0.5"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"> 
        <EasingDoubleKeyFrame.EasingFunction> 
         <BackEase EasingMode="EaseOut" Amplitude="0.25"/> 
        </EasingDoubleKeyFrame.EasingFunction> 
       </EasingDoubleKeyFrame> 
      </DoubleAnimationUsingKeyFrames> 
      <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="window"> 
       <EasingColorKeyFrame KeyTime="0" Value="Transparent"/> 
       <EasingColorKeyFrame KeyTime="0:0:0.5" Value="White"> 
        <EasingColorKeyFrame.EasingFunction> 
         <BackEase EasingMode="EaseOut"/> 
        </EasingColorKeyFrame.EasingFunction> 
       </EasingColorKeyFrame> 
      </ColorAnimationUsingKeyFrames> 
     </Storyboard> 
     <Storyboard x:Key="ShrinkFrame"> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="window"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="256"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="32"> 
        <EasingDoubleKeyFrame.EasingFunction> 
         <CubicEase EasingMode="EaseInOut"/> 
        </EasingDoubleKeyFrame.EasingFunction> 
       </EasingDoubleKeyFrame> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="window"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="256"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="32"> 
        <EasingDoubleKeyFrame.EasingFunction> 
         <CubicEase EasingMode="EaseInOut"/> 
        </EasingDoubleKeyFrame.EasingFunction> 
       </EasingDoubleKeyFrame> 
      </DoubleAnimationUsingKeyFrames> 
      <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="window"> 
       <EasingDoubleKeyFrame KeyTime="0" Value="1"/> 
       <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0.5"> 
        <EasingDoubleKeyFrame.EasingFunction> 
         <CubicEase EasingMode="EaseInOut"/> 
        </EasingDoubleKeyFrame.EasingFunction> 
       </EasingDoubleKeyFrame> 
      </DoubleAnimationUsingKeyFrames> 
      <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="window"> 
       <EasingColorKeyFrame KeyTime="0" Value="White"/> 
       <EasingColorKeyFrame KeyTime="0:0:0.5" Value="Transparent"> 
        <EasingColorKeyFrame.EasingFunction> 
         <CubicEase EasingMode="EaseInOut"/> 
        </EasingColorKeyFrame.EasingFunction> 
       </EasingColorKeyFrame> 
      </ColorAnimationUsingKeyFrames> 
     </Storyboard> 
    </Window.Resources> 
    <Window.Triggers> 
     <EventTrigger RoutedEvent="Mouse.MouseEnter"> 
      <BeginStoryboard Storyboard="{StaticResource GrowFrame}"/> 
     </EventTrigger> 
     <EventTrigger RoutedEvent="Mouse.MouseLeave"> 
      <BeginStoryboard x:Name="ShrinkFrame_BeginStoryboard" Storyboard="{StaticResource ShrinkFrame}"/> 
     </EventTrigger> 
    </Window.Triggers> 
</Window> 
+0

후 지금까지 시도 코드는 ... – Sankarann

+0

블렌더는 어떤 마크 업이라고 XAML을 생산 당신이 속성을 설정할 때. 그것을 식별하고 질문을 업데이트 할 수 있다면 우리가 설정 한 속성 중 어떤 것이 잘못되었는지 알아 내려고 할 수 있습니다. –

+0

@sankarann ​​우리가 간다. –

답변

0

다른 사람들도 지적했듯이 새로운 프레임 워크 릴리스에는 동기 애니메이션을 방지하는 버그가 있습니다. 그러나, 저를 위해 아주 잘 작동하는 빠른 해결책은 여기있다. 그것은 단순한 것 이상의 것이므로 어떠한 설명도 순서에 있다고 생각하지 않습니다. 그것은 작동, 그것은 모든 문제의 :

XAML :

<Window x:Class="App.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="32" Width="32" ResizeMode="NoResize" WindowStyle="None" 
    MouseEnter="MouseEntered" MouseLeave="MouseLeft"> 
</Window> 

코드 숨김 :

using System.Windows; 
using System.Windows.Input; 

namespace App 
{ 
    public partial class MainWindow : Window 
    { 
     private const int MAX_WINDOW_SIZE = 256; 
     private const int MIN_WINDOW_SIZE = 32; 
     private const int ANIMATION_SPEED = 10; 

     public MainWindow() 
     { 
      InitializeComponent(); 
     } 

     private void MouseEntered(object sender, MouseEventArgs e) 
     { 
      while (this.Width <= MAX_WINDOW_SIZE) 
      { 
       this.Width += ANIMATION_SPEED; 
       this.Height += ANIMATION_SPEED; 
      } 
     } 

     private void MouseLeft(object sender, MouseEventArgs e) 
     { 
      while (this.Width >= MIN_WINDOW_SIZE) 
      { 
       this.Width -= ANIMATION_SPEED; 
       this.Height -= ANIMATION_SPEED; 
      } 
     } 
    } 
} 
+0

답변 주셔서 감사합니다. 그러나 좀 더 검색 한 후에 Window의 너비와 높이를 움직이는 것이 .NET 3.5에서 작동한다는 것을 알았습니다 ... 4.5.1에서 왜 안 되니? 버그 같아. –

+0

@SuperDisk 음, 확실하지 않습니다. 나는 많은 연구를 조용히했고이 문제를 해결할 해결책을 찾지 못했습니다. 내가 제공 한 솔루션은 나 자신을 사용하고있다. 때로는 간단한 방법이 최선의 방법이다. –

2

WPF는 (당신이 시도로) 모두 동기화 애니메이션을 지원하고 중복 HandoffBehavior를 제공하는 애니메이션. 해결 방법으로 작동하는지 확인해보십시오. 그러나 이것은 알려진 버그라고 생각합니다 (https://connect.microsoft.com/VisualStudio/feedback/details/715415/window-width-height-animation-in-wpf-got-broken-on-net-framework-4-0). 나는 그것이 지금까지 고쳐지지 않았다는 것에 충격을 받았다.

+1

"당신의 의견에 진심으로 감사드립니다.이 시점에서 우리는 제품의이 영역에서 어떤 변화도 일으키지 않을 것입니다. 감사합니다! Wpf 팀" –

+1

그렇습니다. 그들은 그들의 말에 충실합니다. 나는 그들이 그 의미를 이해했다고 생각하지 않는다. – user2023266

0

는 다른 방법으로, 단지 해결 방법으로 고정 된 크기의 투명 창을 사용 :

<Window x:Name="window" x:Class="RectangleWindow" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      Title="RectangleWindow" Height="300" Width="300" ResizeMode="NoResize" WindowStyle="None" 
      Background="Transparent" AllowsTransparency="True"> 
     <Window.Resources> 
      <Storyboard x:Key="GrowFrame"> 
       <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="insideRectangle"> 
        <EasingDoubleKeyFrame KeyTime="0" Value="32"/> 
        <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="256"> 
         <EasingDoubleKeyFrame.EasingFunction> 
          <BackEase EasingMode="EaseOut" Amplitude="0.25"/> 
         </EasingDoubleKeyFrame.EasingFunction> 
        </EasingDoubleKeyFrame> 
       </DoubleAnimationUsingKeyFrames> 
       <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="insideRectangle"> 
        <EasingDoubleKeyFrame KeyTime="0" Value="32"/> 
        <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="256"> 
         <EasingDoubleKeyFrame.EasingFunction> 
          <BackEase EasingMode="EaseOut" Amplitude="0.25"/> 
         </EasingDoubleKeyFrame.EasingFunction> 
        </EasingDoubleKeyFrame> 
       </DoubleAnimationUsingKeyFrames> 
      </Storyboard> 
      <Storyboard x:Key="ShrinkFrame"> 
       <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="insideRectangle"> 
        <EasingDoubleKeyFrame KeyTime="0" Value="256"/> 
        <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="32"> 
         <EasingDoubleKeyFrame.EasingFunction> 
          <CubicEase EasingMode="EaseInOut"/> 
         </EasingDoubleKeyFrame.EasingFunction> 
        </EasingDoubleKeyFrame> 
       </DoubleAnimationUsingKeyFrames> 
       <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="insideRectangle"> 
        <EasingDoubleKeyFrame KeyTime="0" Value="256"/> 
        <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="32"> 
         <EasingDoubleKeyFrame.EasingFunction> 
          <CubicEase EasingMode="EaseInOut"/> 
         </EasingDoubleKeyFrame.EasingFunction> 
        </EasingDoubleKeyFrame> 
       </DoubleAnimationUsingKeyFrames> 
      </Storyboard> 
     </Window.Resources> 
     <Window.Triggers> 
      <EventTrigger RoutedEvent="Mouse.MouseEnter"> 
       <BeginStoryboard Storyboard="{StaticResource GrowFrame}"/> 
      </EventTrigger> 
      <EventTrigger RoutedEvent="Mouse.MouseLeave"> 
       <BeginStoryboard x:Name="ShrinkFrame_BeginStoryboard" Storyboard="{StaticResource ShrinkFrame}"/> 
      </EventTrigger> 
     </Window.Triggers> 

     <Rectangle x:Name="insideRectangle" Fill="White" 
      Width="50" Height="50" 
      HorizontalAlignment="Left" 
      VerticalAlignment="Top"> 
      <Rectangle.BitmapEffect> 
       <DropShadowBitmapEffect/> 
      </Rectangle.BitmapEffect>  
     </Rectangle> 
    </Window>