cimbalino/Cimbalino-Toolkit

WPA81 NavigationService design-time error when used with MVVM Light?

P2SH opened this issue · 1 comments

P2SH commented

ViewModelLocator

using Cimbalino.Toolkit.Services;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;

namespace App1.ViewModel
{
    public class ViewModelLocator
    {
        public MainViewModel Main { get { return ServiceLocator.Current.GetInstance<MainViewModel>(); } }

        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
            SimpleIoc.Default.Register<INavigationService, NavigationService>();
            SimpleIoc.Default.Register<MainViewModel>();
        }
    }
}

ViewModel

using Cimbalino.Toolkit.Services;
using GalaSoft.MvvmLight;

namespace App1.ViewModel
{
    public class MainViewModel : ViewModelBase
    {
        public MainViewModel(INavigationService navigationService)
        {
        }
    }
}

Page

<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    DataContext="{Binding Source={StaticResource Locator}, Path=Main}">

    <Grid />
</Page>

Error when building the first time/after reopening the xaml

Error   1   The method or operation is not implemented. c:\users\name\documents\visual studio 2013\Projects\App1\App1\MainPage.xaml 10  5   App1

Error when rebuilding

Error   1   Could not find Windows Runtime type 'Windows.UI.Xaml.TickBar'.  c:\users\name\documents\visual studio 2013\Projects\App1\App1\MainPage.xaml 10  5   App1

No error if INavigationService is removed from the ViewModel's constructor.

Thanks for the fix! :)