我正在开发一个Windows Phone 7.0的应用程序,我试图添加一个示例设计数据文件,以便在使用Visual Studio时获得一些图形。 字符串或int类型正常工作,但不是自定义对象。WP7 DesignData与自定义对象
我解释一下:
我有这样一个类:(代表我的自定义对象)
public class CustomObject
{
public string Title { get; set; }
}
这是我的视图模型:
public class MainViewModel
{
public MainViewModel()
{
this.Custom= new CustomObject();
this.Custom.Title = "Hey, i'm the Runtime Custom";
}
public CustomObject Custom{ get; set; }
public string TestProperty { get; set; }
}
我创建了一个样本数据文件是这样的:
<local:MainViewModel
xmlns:local="clr-namespace:Project.ViewModels"
TestProperty ="I'm the Design testProperty and I work">
<local:MainViewModel.Custom Title="Hey, i'm the Design Custom, and I don't work" />
</local:MainViewModel>
在我的应用程序的主页,我已经在手机标签中添加此:
d:DataContext="{d:DesignData SampleData.xaml}"
好吧,当我用那样的TestProperty变量(Text="{Binding TestProperty}"
)测试,它工作正常,但是当我尝试我的对象是这样的(Text="{Binding Custom.Title}"
),它不起作用...
我发现的所有资源都无法谈论自定义对象。
有没有人有什么想法?
坦克。
PS:我tryed添加DesignData标签(什么最能描述我的问题),但我不能:(
编辑: 无需编译,Visual Studio中不显示任何内容,我compil,它显示Hey, i'm the Runtime Custom
......它绕过我的样本数据文件,但仅限于该自定义对象
它不工作不幸... 当我尝试,Visual Studio下划线'local:Custom'并说:没有找到类型local:Custom。 – HeyBob