Raffy Alcoriza
Raffy Alcoriza

Reputation: 147

The name doesn't exist in the namespace

Help! I can't do data binding properly on my Windows Phone 8.1 WinRT app.

Here's my 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 located in a ViewModels folder:

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 error showing up on my error list is: The name "TermsViewModel" does not exist in the namespace "using:Neomilano.ViewModels".

To note, I am using Tim Heuer's private build of SQLite for WP 8.1. Already tried restarting Visual Studio, but it's no good.

UPDATE: I tried placing my pages, which are under the Neomilano namespace, as static resources. No problems there, so I tried to move out the ViewModels out of the Neomilano.ViewModels namespace, while remaining on their folder structure in the project. The pages remain to be free from errors, but the ViewModels, together with the Models (they also have their own folder), doesn't work and gets the same error.

UPDATE: I discovered something that is probably linked to this issue. I posted it on a separate submission.

More details to be provided if needed.

Thank you! :)

Upvotes: 1

Views: 1815

Answers (1)

Shahar Prish
Shahar Prish

Reputation: 4847

  1. Close VS.
  2. Delete all (hidden) SUO files - there may be 2.
  3. Rerun VS. Ghost errors should be gone.

Upvotes: 1

Related Questions