如何使用DesignData来帮助开发地铁应用程序? [英] How can I use DesignData to help develop a Metro app?

查看:244
本文介绍了如何使用DesignData来帮助开发地铁应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在欢快使用DesignData在Windows Phone应用,并且我希望用它来帮助可视化在VS2012 /混合为VS Metro风格应用的设计。

I've been merrily using the DesignData in Windows Phone apps, and I was hoping to use it to help visualise designs in a Metro style app in VS2012/Blend for VS.

我已经试过希望显而易见的:

I've tried the hopefully obvious:

<common:LayoutAwarePage
x:Name="pageRoot"
x:Class="MyRootNamespace.Views.EventView"
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:MyRootNamespace.Views"
xmlns:common="using:MyRootNamespace.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:bm="using:Bing.Maps"
d:DataContext="{d:DesignData Source=../SampleData/SpecialEventSampleData.xaml}"
mc:Ignorable="d">



随着SpecialEventSampleData.xaml寻找松散,如:

With the SpecialEventSampleData.xaml looking loosely like:

<local:SpecialEvent 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyRootNamespace.ViewModels" 
EventName="Foo Fighters" 
Description="This exclusive April Fools Gig will see Dave Grohl and the rest of the Foo Fighters rock out at this exclusive made up gig" 
VenueName="Village Hall" 
/>

的类,它是指有一个公共,无参数的构造函数,但Visual Studio是给了一个错误:

The class to which it refers has a public, parameterless constructor, but Visual Studio is giving an error:

错误无法创建SpecialEvent的一个实例。 C:... \MyRootNamespace.Windows\SampleData\SpecialEventSampleData.xaml

Error Cannot create an instance of "SpecialEvent". C:...\MyRootNamespace.Windows\SampleData\SpecialEventSampleData.xaml

另外,我期待有设置构建行动DesignData,或类似的,但这并不似乎是在Visual Studio 2012中的一个选项?

In addition, I was expecting to have to set the build action to "DesignData", or similar, but this doesn't appear to be an option in Visual Studio 2012?

什么我需要做的是能够得到设计时数据以在VS2012的工作/混合?

What do I need to do to be able to get design time data to work in VS2012/Blend?

推荐答案

时,SpecialEvent您的视图模型?如果是这样,你可以做这样的事情在你的XAML(后直接您共同:LayoutAwarePage开业申报)

Is SpecialEvent your ViewModel? If so, can you do something like this in your XAML (directly after your common:LayoutAwarePage opening declaration)?

<d:Page.DataContext>
    <local:SpecialEvent>
</d:Page.DataContext>



然后再从您共同删除此行$ b

And then remove this line from your common:LayoutAwarePage:

d:DataContext="{d:DesignData Source=../SampleData/SpecialEventSampleData.xaml}" 

我有类似这样的工作代码。

I have code similar to this that is working.

这篇关于如何使用DesignData来帮助开发地铁应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆