1
我創建了一個翻轉動畫,從項目列表轉到編輯對話框。例如,用戶看到項目列表,雙擊項目進行編輯,屏幕翻轉以顯示編輯對話框的詳細信息。Silverlight屏幕翻轉後動畫模糊
我有實際的動畫工作,除了在屏幕上的項目有點模糊。當我翻回到也是模糊的列表。
任何人都可以爲此提出建議。我已經在下面展示了我是如何實現翻轉的。
<ContentControl x:Name="EditPtrMainContent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ContentControl.Resources>
<Storyboard x:Name="FlipToEditStart">
<DoubleAnimation From="0" To="90" Duration="0:0:0.3" Storyboard.TargetName="ContentProjection" Storyboard.TargetProperty="RotationY"/>
</Storyboard>
<Storyboard x:Name="FlipToEditEnd">
<DoubleAnimation From="270" To="360" Duration="0:0:0.3" Storyboard.TargetName="ContentProjection" Storyboard.TargetProperty="RotationY"/>
</Storyboard>
<Storyboard x:Name="FlipToListStart">
<DoubleAnimation From="0" To="-90" Duration="0:0:0.3" Storyboard.TargetName="ContentProjection" Storyboard.TargetProperty="RotationY"/>
</Storyboard>
<Storyboard x:Name="FlipToListEnd">
<DoubleAnimation From="-270" To="-360" Duration="0:0:0.3" Storyboard.TargetName="ContentProjection" Storyboard.TargetProperty="RotationY"/>
</Storyboard>
</ContentControl.Resources>
<ContentControl.Projection>
<PlaneProjection x:Name="ContentProjection"/>
</ContentControl.Projection>
</ContentControl>
並在代碼隱藏(本質上是一個MVVM應用程序,但我很高興在觀看動畫的控制是因爲它是視覺)
public EditPtrView()
{
InitializeComponent();
Loaded += OnLoaded;
Unloaded += OnUnloaded;
FlipToEditStart.Completed += OnFlipToEditStartCompleted;
FlipToListStart.Completed += OnFlipToListStartCompleted;
}
void OnFlipToListStartCompleted(object sender, EventArgs e)
{
EditPtrMainContent.Content = new EditPtrView();
FlipToListEnd.Begin();
}
void OnFlipToEditStartCompleted(object sender, EventArgs e)
{
EditPtrMainContent.Content = new NamedTransferView();
FlipToEditEnd.Begin();
}
void OnLoaded(object sender, RoutedEventArgs e)
{
// register for MVVM Light messages
AppMessages.SetFocusMessage.Register(this, OnSetFocus);
AppMessages.CloseScreenMessage.Register(this, OnCloseScreen);
AppMessages.ViewLoadedMessage.Send(ViewTypes.BookingsListView);
}
void OnUnloaded(object sender, RoutedEventArgs e)
{
AppMessages.SetFocusMessage.Unregister(this, OnSetFocus);
AppMessages.CloseScreenMessage.Unregister(this, OnCloseScreen);
}
#region MVVM Light Message Delegates
private void OnCloseScreen(string screenName)
{
switch (screenName)
{
case "PtrEdit":
FlipToListStart.Begin();
break;
}
}
#endregion
private void TransfersDataGridDoubleClick(object sender, MouseButtonEventArgs e)
{
ShowEditScreen();
}
private void EditPtrButtonClick(object sender, RoutedEventArgs e)
{
ShowEditScreen();
}
private void ShowEditScreen()
{
FlipToEditStart.Begin();
}
正如你可以看到我開始上半場雙擊(或按鈕單擊)並將動畫設置爲90度。然後當這個動畫完成時,我將ContentControl的內容更改爲新屏幕,並啓動第二個動畫從270度到360度。使用編輯屏幕上的MVVM Light Messenger調用,我會執行反向動畫以返回列表。所有這些工作都很好,但正如我所說,屏幕稍微模糊了。我並沒有想象它,因爲編輯屏幕是一個View/ViewModel,它也在其他地方使用,所以很容易比較。 在動畫的最後需要做些什麼來正確地重畫屏幕?