Windows Store App设计时数据的应用

想象这么一个场景:我们在做开发的时候写了一个GirdView并且对GridView的DataTemplate做了布局以及绑定,于是VS设计器中出现了一个框,但是开发人员并不能很好的预料到如果数据填充进去会有什么样的结果,举个例子来说可能长度或者高度设计的不够,导致某个远程图片被缩放变形,同时后期修改会产生大量的项目延迟。 这个时候我们需要使用VS来显示一些设计时数据。 情况一,数据源为本地数据 这种情况是最好的,绑定完成之后debug就可以看到数据显示是否符合需求,稍作修改便可。请参考如何绑定到分层数据并创建主视图/详细信息视图。 情况二,数据源为远程数据 当然你可以使用本地数据作为测试,下面这段代码可以在测试时帮助调用一些本地的测试数据 Fake Date if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) {       GetSampleData(); } else GetRealData(); 同样的,这种方式也仅仅只能在Debug下才能看到数据显示是否正确,如果想在设计时看到数据,那么我们需要其他的一些代码。 情况三,设计时显示测试数据  上图所示就是在设计时候显示的数据,而作为对比,下图为运行时数据 我们需要做的就是 Step1, 定义设计时所需要的数据,我这里创建了一个叫DesignTimeDataCenter的类专门用于放置测试数据 Step2,完善绑定,在此声明下,具有 d: 前缀的属性仅在设计时被解释,而在运行时被忽略。所以绑定的属性可以用d:Source 来实现。 Step3,修改排版,让界面看起来更完美。 具体的代码我贴一部分在这里,其他的大家可以在我的SkyDrive上下载,地址为:http://1drv.ms/1cwIj2c MainPage.XAML文件: <Page  x:Class=”DesignTimeData.MainPage”    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”    xmlns:local=”using:DesignTimeData”      xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″    xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″     DataContext=”{Binding RelativeSource={RelativeSource Self}}”     d:DataContext=”{Binding Source={d:DesignInstance Type=local:DesignTimeDataCenter, IsDesignTimeCreatable=True}}”     mc:Ignorable=”d”>      <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”>         <GridView ItemsSource=”{Binding News}”>             <GridView.ItemTemplate>…

0

Using database in Windows Store apps (I)

Author: Aaron Xue Introduction There are lots of discussions about using database in Windows Store apps in MSDN forum. These discussions mainly focus on the usage of SQL database. Based on this scenario, we developed a series of articles along with sample code and demos used to demonstrate how to access both local database and…

16

Using HTML5/Javascript in Windows Store apps: Data access and storage mechanism (III)

Introduction Windows Store app offers lots of methods for data access and storage. And this article will only focus on HTML5/JavaScript programming. In this tutorial, we’ll go over Application Data, File API , HTML5 Web Storage, Indexed Database API and remote data access. With these you can store more data – and store it more…

0

Porting Desktop Apps to Windows Store Apps

Author: Han Xia Windows Store Applications bring a brand new look and user experience. It’s also a great challenge for the Windows developers who are familiar with the desktop applications development to adapt to the new interface and programing model. In this article, I try to provide the generic guideline on how to port desktop…

4

Using HTML5/Javascript in Windows Store apps: Data access and storage mechanism (II)

  Introduction Windows Store app offers lots of methods for data access and storage. And this article will only focus on HTML5/JavaScript programming. In this tutorial, we’ll go over Application Data, File API , HTML5 Web Storage, Indexed Database API and remote data access. With these you can store more data – and store it…

0

Using HTML5/Javascript in Windows Store apps: Data access and storage mechanism (I)

 Author: Roy Tian Introduction Windows Store app offers lots of methods for data access and storage. And this article will only focus on HTML5/JavaScript programming. In this tutorial, we’ll go over Application Data, File API , HTML5 Web Storage, Indexed Database API and remote data access. With these you can store more data – and…

0

Introduce multi-thread programming in Windows Store apps Part II

Introduction   We will post a blog series to introduce multi-threading programming in Windows Store app. In this blog series, we will walk through a sample together to demonstrate which multi-threading APIs can be used, how to create a thread, and synchronization. As the second part in this series, this article will introduce how to…

1

Introduce multi-thread programming in Windows Store apps Part I

Introduction   We will post a blog series to introduce multi-threading programming in Windows Store app. In this blog series, we will walk through a sample together to demonstrate which multi-threading APIs can be used, how to create a thread, and synchronization. In this blog, we will introduce which Win32 multi-threading APIs can be used…

1

Porting iOS Apps to Windows 8 (5): Storing Data and Preferences

Author: Rafe Wu   Channel 9 https://channel9.msdn.com/Blogs/OneCode/How-to-Port-iOS-apps-to-Windows-Store-apps Windows 8 features a very comprehensive system of managing data for applications. This section compares the Application Preference features of Windows 8 and iOS. Application Preference The following table shows how we store application settings on the two platforms.   iOS Windows Store Application Application Preferences System wide…

0

Porting iOS Apps to Windows 8 (4): Application Lifecycle Differences

Author: Rafe Wu   Channel 9 https://channel9.msdn.com/Blogs/OneCode/How-to-Port-iOS-apps-to-Windows-Store-apps Technically speaking, both the iOS and the Windows Store applications allow only one application to execute in the foreground at a time. The foreground application owns the screen and receives the touch events. They both support multitasking and fast application switch. However, the execution model of iOS apps…

0