Silverlight找不到页面错误
我已经开始了一个新项目(以重构一些代码),但无法弄清楚为什么我不断收到“找不到页面/索引”错误。代码工作正常,直到我使用 add 方法(在任何集合类型上)。所以我不认为导航有问题,而是我的 IndexViewModel 类有问题。
公共部分类索引:页 { 私有 IndexViewModel _vm;
public Index()
{
InitializeComponent();
_vm = new IndexViewModel();
...
public class IndexViewModel //: ViewModelBase
{
public SortableCollectionView Rows {get;set;}
public IndexViewModel()
{
// generate some dummy data
Random rand = new Random();
for (int i = 0; i < 200; i++)
{
Row row = new Row();
row["stuff"] = s_names[rand.Next(s_names.Length)];
**Rows.Add(row);**
}
}
I have started a a new project (to refactor some code), and just can't work out why I keep getting "Can't find page /Index" error. The code works fine until I use an add method (on any collection type). So I don't think there is a problem with the navigation, but an issue with my IndexViewModel class.
public partial class Index : Page
{
private IndexViewModel _vm;
public Index()
{
InitializeComponent();
_vm = new IndexViewModel();
...
public class IndexViewModel //: ViewModelBase
{
public SortableCollectionView Rows {get;set;}
public IndexViewModel()
{
// generate some dummy data
Random rand = new Random();
for (int i = 0; i < 200; i++)
{
Row row = new Row();
row["stuff"] = s_names[rand.Next(s_names.Length)];
**Rows.Add(row);**
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您从未更新过 Rows 变量。
要得到实际的错误,您可以使用从我的答案中复制的技巧 另一个问题:
要查看问题所在,您需要对 MainPage.xaml.cs 进行一项更改:
在启动时进行更改后应用程序中,您应该看到异常而不是发生异常的页面。
Looks like you never new up your Rows variable.
To get to the actual error you can use this trick copied from my answer on another question:
To see what the issue is you need to make one change to your MainPage.xaml.cs:
Once you've made that change when you start the application you should see the exception instead of the page where the exception occurred.
您需要
在代码中的某个地方。
You need
somewhere in your code.