0
WP 7.5應用程序。我有兩個Storyboard動畫 - 一個在圖像上,另一個在文本上。使用Obscure和UnObscure ...我正在做對嗎?
問題1:當我移動到下一頁並返回時,圖像和文字閃爍。
解決方法1:所以我添加OnNavigateFrom和明確地停止動畫,還參與了動畫的任何屬性重置爲0
Issue2:現在說在屏幕進入鎖定模式,當我解鎖,因爲我在OnNavigatedFrom中將我的一個元素的不透明度設置爲0,所以元素被隱藏,實際上應該是可見的,直到用戶移動到下一頁。
解決方案2:我在代碼中處理了如下所示的遮罩和未遮罩的處理程序,並添加了一個標記以查看應用程序是否會遮擋模式,請勿停止動畫或重置屬性。
public class Page2 :PhoneApplicationPage
{
private bool _isObscured = false;
public Page2()
{
(Application.Current as App).RootFrame.Obscured += OnObscured;
(Application.Current as App).RootFrame.Unobscured += OnUnobscured;
InitializeComponent();
}
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
//Stop animations and reset properties only if not going to obscure mode.
if (!_isObscured)
{
//stop animaiton
Storyboard1.Stop();
Storyboard2.Stop();
//Reset all transform properties to 0
Text1.Opacity = 0;
Image1.RenderTransform.SetValue(CompositeTransform.ScaleXProperty, 0.0);
Image1.RenderTransform.SetValue(CompositeTransform.ScaleYProperty, 0.0);
}
base.OnNavigatedFrom(e);
}
void OnObscured(object sender, ObscuredEventArgs e)
{
Storyboard1.Pause();
Storyboard2.Pause();
_isObscured = true;
}
void OnUnobscured(object sender, EventArgs e)
{
Storyboard1.Resume();
Storyboard2.Resume();
_isObscured = true;
}
}
問題:這是要走的路corret還是有更好的辦法?這樣做會不會有任何認證問題?
任何幫助真的很感激。
我完全不明白嗎?當屏幕鎖定被遮擋時,這會如何提供幫助? – oms 2011-12-24 17:33:58
在這種情況下,當屏幕被鎖定時,OnNavigatedFrom方法中不再有不透明度的變化。所以,當你回來時 - 所有元素仍然可見。並且您的Solution1不生成問題2,我認爲 – Ku6opr 2011-12-24 18:58:35
我明白了。我將不得不測試一下。另外我的NavigationService.NavigateTo()在一個customControl中,它通過MouseLeftButtonDown處理我的圖像的導航。我會嘗試更新。謝謝。 – oms 2011-12-24 20:24:03