Search code examples
xamlwindows-runtimewindows-phone-8winrt-xamlexpression-blend

Use Windows Phone sample data in WinRT


I'm making a Windows 8 program with MVVM that shares the MVM part with Phone.

My problem is that when I try to use the XAML sample data of the Windows Phone project in WinRT I get a bunch of errors. My XAML is:

<vm:MyViewModel
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:MyApp.ViewModels" 
>

This is obviusly faulty, because uses the clr-namespace directive. But if I change it to

<vm:MyViewModel
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:MyApp.ViewModels" 
>

I get the same bunch of errors, such as

The name "MyViewModel" does not exist in the namespace "using:MyApp.ViewModels"

Can I use XAML files as sample in WinRT as in Windows Phone? How can I solve this errors?

thanks :)


Solution

  • Quite strange but the problem was that, for some reason, the compiler didn't recognize the ViewModel classes even if they where there.

    Workaround: Delete the XAML sample data files, clean&build; then, re-create the XAML sample data files (with the same code inside!), works like a charm.