VS 11 Split application program analysis

3022 단어 application
Let's take a look at how to turn a page into a startup page

  • In the onLanched event, put,

      Window.Current.Content = _rootFrame;
    
     Window.Current.Activate();
    
     var _rootFrame = new Frame();
    
     _rootFrame.Navigate(typeof(ItemsPage), sampleData.ItemGroups);
    
    ///  Window.Current.Content , .Activate();
    Then look at what's in the ItemsPage, look at the inheritance relationship
  • public sealed partial class ItemsPage : Application6.Common.LayoutAwarePage
  • [Windows.Foundation.Metadata.WebHostHidden] public class LayoutAwarePage : Page///or inherit from page, then see why they have LayoutAwarePage, this class
  • New LayoutAwarePage() will be called before new ItemsPage(), that is, the constructor and fields in LayoutAwarePage will be run first; because of the inheritance relationship
  • The DataContext that LayoutAwarePage inherits from page is public, this.DataContext = _defaultViewModel;, which adds data context to the page inherited from LayoutAwarePage
  • In ItemPage, call this protected override void OnNavigatedTo(NavigationEventArgs e) { this.DefaultViewModel["Items"] = e.Parameter; } to set datacontext for itemPage, because the datacontext of itempage inherits from LayoutAwarePage and is pointing to _defaultViewModel, reference, when the object that _defaultViewModel only wants to change, the datacontext for itempage will also change, so why does LayoutAwarePage have protected IObservableMap DefaultViewModel { get { return _defaultViewModel; } }? , look at its gaze

  • //////Gets an implementation of set as the///page's default . This instance can be bound and surfaces///property change notifications making it suitable for use as a trivial view model.///By default, datacontext is set for each inherited from LayoutAwarePage, this is just for trial ViewMoDEL, if you want to change it
    this.DefaultViewModel["Items"] = e.Parameter;, set different strings and objects, that's it
    8 ItemsPage has a CollectionViewSource, object, CollectionViewSource. SOURCE , referenced to e.Parameter by binding to this.DefaultViewModel["Items"]

    Then the control in the ItemsPage can be bound to the CollectionViewSource

    좋은 웹페이지 즐겨찾기