コード例 #1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }
            var item = SampleDataSource.GetItem((String)navigationParameter);

            this.flipView.SelectedItem = item;
        }
コード例 #2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var sampleItems = SampleDataSource.GetItems((String)navigationParameter);

            try
            {
                Assembly asm = typeof(MainPage).GetTypeInfo().Assembly;
                using (Stream stream = asm.GetManifestResourceStream("FlexChart101.Resources.SamplesCodes.zip"))
                {
                    using (C1ZipFile zip = new C1ZipFile(stream))
                    {
                        bool isMobileDevice = LayoutAwarePage.IsWindowsPhoneDevice();
                        sampleItems.ToList <SampleDataItem>().ForEach(sampleItem =>
                        {
                            var ets = zip.Entries.Where(entry => entry.FileName.Equals(sampleItem.SourceCodes.XamlFileName) ||
                                                        entry.FileName.Equals(sampleItem.SourceCodes.CodeFileName) ||
                                                        (entry.FileName.Contains("DeviceFamily-Mobile/")) && entry.FileName.Contains(sampleItem.SourceCodes.XamlFileName));
                            ets.ToList <C1ZipEntry>().ForEach(entry =>
                            {
                                if (entry.FileName.Contains("xaml.cs"))
                                {
                                    sampleItem.SourceCodes.Code = GetContent(entry);
                                }
                                else if (ets.Count() == 2 || (isMobileDevice && entry.FileName.Contains("DeviceFamily-Mobile/") ||
                                                              !isMobileDevice && !entry.FileName.Contains("DeviceFamily-Mobile/")))
                                {
                                    sampleItem.SourceCodes.Xaml = GetContent(entry);
                                }
                            });
                        });
                    }
                }
            }
            catch
            {
            }
            this.DefaultViewModel["AllItems"] = sampleItems;
        }
コード例 #3
0
 public ItemDetailPage()
 {
     this.InitializeComponent();
     this.flipView.ItemsSource = SampleDataSource.GetItems("AllItems");
 }