帮助!我无法在Windows Phone 8.1 WinRT应用程序上正确进行数据绑定。
这是我的App.xaml:
<Application x:Class="Neomilano.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Neomilano">
<Application.Resources>
<ResourceDictionary Source="/Dictionary.xaml" />
</Application.Resources>
Dictionary.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Neomilano"
xmlns:conv="using:Neomilano.Converters"
xmlns:vm="using:Neomilano.ViewModels">
<x:String x:Key="ApplicationName">Neomilano</x:String>
<!--converters available in Neomilano.Converters-->
<conv:StringToLowerConverter x:Key="StringToLowerConverter" />
<conv:StringToUpperConverter x:Key="StringToUpperConverter" />
<vm:TermsViewModel x:Key="TermsVM" />
TermsViewModel.cs位于ViewModels文件夹中:
using Neomilano.Model;
using SQLite;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Neomilano.ViewModels
{
public class TermsViewModel : BaseViewModel
{
private ObservableCollection<Term> terms;
public ObservableCollection<Term> Terms {
get { return this.terms; }
private set
{
if (terms != value)
{
terms = value;
NotifyPropertyChanged("Terms");
}
}
}
public TermsViewModel()
{
}
/// <summary>
/// Gets the list of Terms from the database and adds it to the Terms property of the ViewModel.
/// </summary>
/// <returns></returns>
public async Task GetTermsList()
{
//var db = new SQLiteAsyncConnection(app.DBPath);
//var list = await db.Table<Term>().ToListAsync();
//terms = new ObservableCollection<Term>(list);
List<Term> list = new List<Term>();
await Task.Run(() =>
{
var db = new SQLiteConnection(app.DBPath);
list = db.Table<Term>().ToList<Term>();
});
Terms = new ObservableCollection<Term>(list);
Debug.WriteLine("Check terms now");
}
}
}
错误列表中显示的错误是:The name "TermsViewModel" does not exist in the namespace "using:Neomilano.ViewModels".
需要注意的是,我正在使用Tim Heuer的私人构建的SQLite for WP 8.1。已经尝试重新启动Visual Studio,但它没有用。
更新:我尝试将位于Neomilano
命名空间下的网页作为静态资源放置。没有问题,所以我试图从Neomilano.ViewModels
命名空间中移出ViewModels,同时保留在项目中的文件夹结构中。这些页面仍然没有错误,但ViewModels和Models(它们也有自己的文件夹)不起作用并且得到相同的错误。
更新:我发现可能与此问题相关的内容。 I posted it on a separate submission.
如果需要,可提供更多详细信息。
谢谢! :)
答案 0 :(得分:1)