我正在为 Windows Phone 7.0 开发一个应用程序,并且我正在尝试添加一个示例设计数据文件,以便在使用 Visual Studio 时获得一些图形。String 或 int 类型工作正常,但自定义对象不行。
我解释 :
我有一个这样的类:(代表我的自定义对象)
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:我尝试添加 DesignData 标签(最能描述我的问题)但我不允许:(
编辑:
没有编译,Visual Studio 不显示任何内容,当我编译时,它会显示Hey, i'm the Runtime Custom
......它绕过我的示例数据文件,但仅适用于这个自定义对象。