zoukankan      html  css  js  c++  java
  • WPDNews项目中遇到的问题集锦,PivotItem加载问题

    在使用Pivot的过程中,一直有一个问题困扰着我至今还没想到解决办法,先记录下来:


    1. Pivot用作数据绑定,通过数据绑定来实现,它每一个子项PivotItem分别绑定MainViewItem中的一个集合,先假设它有五个PivotItem子项,给他们编号为0,1,2,3,4。现在当模拟机启动,pivot获得焦点的时候内部并不是去取对应的PivotItem绑定的数据集合,而是在取0的同时也会去取1跟4,就是说获得当前焦点的PivotItem的左边的一个跟右边的一个PivotItem都自动去取数据了,顺序是0,1,4;这就麻烦了,本来是控制后段代码加载一个数据显示一个数据的,现在加载一个数据的时候他还是会显示三个数据,所以常常报错的。
    2. 下面的代码的运行顺序出乎我的意料
      public MainPage()
            {
                InitializeComponent();

                // Set the data context of the listbox control to the sample data
                DataContext = App.ViewModel;
                this.Loaded += new RoutedEventHandler(MainPage_Loaded);
            }

            // Load data for the ViewModel Items
            private void MainPage_Loaded(object sender, RoutedEventArgs  )
            {
                if (!App.ViewModel.IsDataLoaded)
                {
                    App.ViewModel.LoadData();
                }
            }
            private void myPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                Debug.WriteLine(myPivot.SelectedIndex);
            }  

     1.先运行MainPage()构造函数这个毫无疑问,但是当this.Loaded += new RoutedEventHandler(MainPage_Loaded);运行之后并不是调用里面所触发的MainPage_Loaded所触发的方法

    2.去执行 myPivot_SelectionChanged方法。

    3.去获得当前前台的PivotItem所绑定的数据 

     
  • 相关阅读:
    Truck History(poj 1789)
    Highways poj 2485
    117. Populating Next Right Pointers in Each Node II
    116. Populating Next Right Pointers in Each Node
    115. Distinct Subsequences
    114. Flatten Binary Tree to Linked List
    113. Path Sum II
    109. Convert Sorted List to Binary Search Tree
    106. Construct Binary Tree from Inorder and Postorder Traversal
    105. Construct Binary Tree from Preorder and Inorder Traversal
  • 原文地址:https://www.cnblogs.com/zhangran/p/2508976.html
Copyright © 2011-2022 走看看