Asked by:
splitpage template non-consistent between simulator and local machine

Question
-
Hi, I am developing metro app using c#. Now I am testing split page template, the code is simple, but result is quite different on local machine and simulator.
local machine:
simulator:
The code is simple.
1. I add a new page "splitpage1" based on template SplitPage.
2. add a class "FeedData"
namespace App10 { // FeedAccount // Holds info for a single account, including a list of device (FeedDevices) public class FeedAccount { public string Name { get; set; } public string Description { get; set; } public DateTime PubDate { get; set; } public List<FeedDevices> FeedDevicesList = new List<FeedDevices>(); } // FeedDevices // Holds info for a single device public class FeedDevices { public FeedDevices(String title, String author) { Title = title; Author = author; } public string Title { get; set; } public string Author { get; set; } public string Content { get; set; } public DateTime PubDate { get; set; } public Uri Link { get; set; } } // FeedDataSource // Holds a method to get FeedAccount. public class FeedDataSource { public static FeedAccount GetFeedAccount() { FeedAccount feedAccount = new FeedAccount(); Debug.WriteLine("GetFeedAccount start"); feedAccount.Name = "testName"; feedAccount.FeedDevicesList.Add(new FeedDevices("first device title", "first device author")); feedAccount.FeedDevicesList.Add(new FeedDevices("second device title", "second device author")); feedAccount.Description = "testDescription"; Debug.WriteLine("GetFeedAccount finish"); return feedAccount; } } }
3. add code-snippet to splitpage1 code-behind:
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { // TODO: Assign a bindable group to this.DefaultViewModel["Group"] // TODO: Assign a collection of bindable items to this.DefaultViewModel["Items"] FeedAccount feedAccount = FeedDataSource.GetFeedAccount(); if (null != feedAccount) { this.DefaultViewModel["Feed"] = feedAccount; this.DefaultViewModel["Items"] = feedAccount.FeedDevicesList; } if (pageState == null) { // When this is a new page, select the first item automatically unless logical page // navigation is being used (see the logical page navigation #region below.) if (!this.UsingLogicalPageNavigation() && this.itemsViewSource.View != null) { this.itemsViewSource.View.MoveCurrentToFirst(); } } else { // Restore the previously saved state associated with this page if (pageState.ContainsKey("SelectedItem") && this.itemsViewSource.View != null) { // TODO: Invoke this.itemsViewSource.View.MoveCurrentTo() with the selected // item as specified by the value of pageState["SelectedItem"] } } }
4. change splitpage1.xaml
<common:LayoutAwarePage x:Name="pageRoot" x:Class="App10.SplitPage1" DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" IsTabStop="false" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App10" xmlns:common="using:App10.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Page.Resources> <!-- Collection of items displayed by this page --> <CollectionViewSource x:Name="itemsViewSource" Source="{Binding Items}"/> <DataTemplate x:Key="DefaultListItemTemplate"> <Grid HorizontalAlignment="Stretch" Width="Auto" Height="110" Margin="10,10,10,0"> <Grid.RowDefinitions> <RowDefinition Height="1*"/> <RowDefinition Height="1*"/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="{Binding Author}" FontSize="26.667" TextWrapping="Wrap" MaxHeight="72" Foreground="#FFFE5815" /> <TextBlock Grid.Row="1" Text="{Binding Title}" FontSize="18.667" /> </Grid> </DataTemplate> </Page.Resources> <!-- This grid acts as a root panel for the page that defines two rows: * Row 0 contains the back button and page title * Row 1 contains the rest of the page layout --> <Grid Style="{StaticResource LayoutRootStyle}"> <Grid.RowDefinitions> <RowDefinition Height="140"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition x:Name="primaryColumn" Width="610"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <!-- Back button and page title --> <Grid x:Name="titlePanel"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding DefaultViewModel.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/> <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{Binding Group.Title}" Style="{StaticResource PageHeaderTextStyle}"/> </Grid> <!-- Vertical scrolling item list --> <ListView x:Name="itemListView" AutomationProperties.AutomationId="ItemsListView" AutomationProperties.Name="Items" TabIndex="1" Grid.Row="1" Margin="-10,-10,0,0" Padding="120,0,0,60" ItemsSource="{Binding Source={StaticResource itemsViewSource}}" IsSwipeEnabled="False" SelectionChanged="ItemListView_SelectionChanged" ItemTemplate="{StaticResource DefaultListItemTemplate}"/>
Could anyone help? Thanks in advance.
dollar zhang
- Edited by Dollar Zhang Monday, July 2, 2012 11:54 AM wrong word
- Moved by Matt SmallMicrosoft employee, Moderator Monday, July 2, 2012 7:46 PM (From:Building Metro style apps with C# or VB )
Monday, July 2, 2012 11:54 AM
All replies
-
This is more of a tools issue, I'm moving over there.
Matt Small - Microsoft Escalation Engineer - Forum Moderator
If my reply answers your question, please mark this post as answered.Monday, July 2, 2012 7:46 PMModerator -
thanks Matt
dollar zhang
Tuesday, July 3, 2012 2:01 AM