2010-11-19 13 views
1

Windows 7 pivot kontrol şablonu projesinde, pivot kontrol sayfası, belirli bir pivot öğesinden arama sayfasına gidip telefondan geri seçeneğini seçerseniz seçilen öğeyi hatırlamıyor. Her zaman pivot kontrolün ilk maddesine geri döner.WP7 pivotcontrol seçilen öğeyi hatırla

Bu davranışı nasıl değiştirirsiniz, böylece 3. dönüş öğesinde olsaydınız ve Arama'ya gidip geri döndüyseniz, 3. dönüş öğesine geri dönersiniz. Pratik

cevap

3

uygulamanızın kaldırıldı edilir Ara düğmesi basın

(diğer kelimeler uygulamasında durduruldu ve mümkün olduğunca uzun süre bellekte tutulur) .Bu tamamen nasıl ele size (geliştirici) kadardır. Sistem, son sayfaya geçiş yapmak için sadece son bir kaç şey yapar. Tarayıcıda çerez gibi düşünebilirsiniz. Geri düğmesine basarsanız, tarayıcı bir çerez olup olmadığını kontrol eder ve içeriği çerezden bilgi ile yükler.

Bunu işlemek ve kullanıcıya en iyi UX'i vermenin çeşitli yolları vardır. Durumu devlet koleksiyonuna veya doğrudan IsolatedStorage'a kaydedebilirsiniz. pivot ile Sayfanız için bir pivot ile App.xaml.cs

yılında

// set state 
    protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) 
    { 
#if DEBUG 
     Debug.WriteLine("TOMBSTONING EVENT: OnNavigatedFrom at {0}", DateTime.Now.ToLongTimeString()); 
#endif 
     //try to locate state if exists 
     if (State.ContainsKey(App.STATE_KEY)) 
     { 
      //clear prev value 
      State.Remove(App.STATE_KEY); 
     } 
     State.Add(App.STATE_KEY, this.State); 
     base.OnNavigatedFrom(e); 
    } 

    // get state 
    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
    { 
     // try to locate the state from previous run 
     if (State.ContainsKey(App.STATE_KEY)) 
     { 
      // return previous state 
      var s = State[App.STATE_KEY] as Info; 
      if (s != null) 
      { 
#if DEBUG 
       Debug.WriteLine("TOMBSTONING EVENT: OnNavigatedTo at {0}", DateTime.Now.ToLongTimeString()); 
#endif 
       this.State = s; 
      } 

     } 

     base.OnNavigatedTo(e); 
    } 

kullanımını bu desen sayfanız için

// Code to execute when the application is launching (eg, from Start) 
    // This code will not execute when the application is reactivated 
    private void Application_Launching(object sender, LaunchingEventArgs e) 
    { 
    } 

    // Code to execute when the application is activated (brought to foreground) 
    // This code will not execute when the application is first launched 
    private void Application_Activated(object sender, ActivatedEventArgs e) 
    { 

    } 

    // Code to execute when the application is deactivated (sent to background) 
    // This code will not execute when the application is closing 
    private void Application_Deactivated(object sender, DeactivatedEventArgs e) 
    { 
    } 

    // Code to execute when the application is closing (eg, user hit Back) 
    // This code will not execute when the application is deactivated 
    private void Application_Closing(object sender, ClosingEventArgs e) 
    { 
    } 

veya olayları olayı kullanın ve pivot kontrolünün son endeksini kaydedin. Deneyin ve blokları da güzel olurdu.

OverviewLifecycle < - Bir film