c# - Errors in App.xaml trying to use MVVM Light in Windows Phone 8 project -


when add mvvm light package via nuget errors referencing lines in app.xaml file added during install. these errors appear in windows phone 8 projects. exact same lines in windows phone 7 project not raise errors. mvvm light added lines are:

<resourcedictionary>     <vm:viewmodellocator x:key="locator" d:isdatasource="true" />      <resourcedictionary.mergeddictionaries></resourcedictionary.mergeddictionaries> </resourcedictionary> 

these lines positioned before ending </application.resources> tag. errors reported in error list pane are:

  • each dictionary must have associated key
  • the name "viewmodellocator" not exist in namespace "clr-namespace:sdkvoicealarmclockwp8cs.viewmodel"

this seems make sense since <resourcedictionary> tag not have key attribute. however, if try move block of lines outside block, whole new set of errors.

as far viewmodellocator problem concerned, double-checked , following namespace added <application> tag attribute , not flagged errors:

xmlns:vm="clr-namespace:sdkvoicealarmclockwp8cs.viewmodel" mc:ignorable="d" 

why exact same set of lines work fine in windows phone 7 project , how can fix namespace problems having in windows phone 8 project?

just in case due more complex problem here entire app.xaml file:

<?xml version="1.0" encoding="utf-8"?> <!--      copyright (c) 2012 microsoft corporation.  rights reserved.     use of sample source code subject terms of microsoft license      agreement under licensed sample source code , provided as-is.     if did not accept terms of license agreement, not authorized      use sample source code.  terms of license, please see      license agreement between , microsoft.      see code samples windows phone, visit http://go.microsoft.com/fwlink/?linkid=219604 --> <application x:class="alarmclockwithvoice.app"               xmlns:phone="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone"               xmlns:shell="clr-namespace:microsoft.phone.shell;assembly=microsoft.phone"               xmlns:toolkit="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone.controls.toolkit"               xmlns:telerikprimitives="clr-namespace:telerik.windows.controls;assembly=telerik.windows.controls.primitives"               xmlns:p1="http://schemas.microsoft.com/winfx/2006/xaml"               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"               xmlns:vm="clr-namespace:sdkvoicealarmclockwp8cs.viewmodel" mc:ignorable="d"              >      <!--application resources-->     <application.resources>         <style x:key="transitionpagestyle" targettype="phone:phoneapplicationpage">             <setter property="toolkit:transitionservice.navigationintransition">                 <setter.value>                     <toolkit:navigationintransition>                         <toolkit:navigationintransition.backward>                             <toolkit:turnstiletransition mode="backwardin" />                         </toolkit:navigationintransition.backward>                         <toolkit:navigationintransition.forward>                             <toolkit:turnstiletransition mode="forwardin" />                         </toolkit:navigationintransition.forward>                     </toolkit:navigationintransition>                 </setter.value>             </setter>             <setter property="toolkit:transitionservice.navigationouttransition">                 <setter.value>                     <toolkit:navigationouttransition>                         <toolkit:navigationouttransition.backward>                             <toolkit:turnstiletransition mode="backwardout" />                         </toolkit:navigationouttransition.backward>                         <toolkit:navigationouttransition.forward>                             <toolkit:turnstiletransition mode="forwardout" />                         </toolkit:navigationouttransition.forward>                     </toolkit:navigationouttransition>                 </setter.value>             </setter>         </style>         <resourcedictionary>             <vm:viewmodellocator x:key="locator" d:isdatasource="true" />             <resourcedictionary.mergeddictionaries></resourcedictionary.mergeddictionaries>         </resourcedictionary>     </application.resources>      <application.applicationlifetimeobjects>         <!--required object handles lifetime events application-->         <shell:phoneapplicationservice launching="application_launching" closing="application_closing" activated="application_activated" deactivated="application_deactivated" />     </application.applicationlifetimeobjects>  </application> 

i had problem before. make work in wp8 replace this:

<resourcedictionary>     <vm:viewmodellocator x:key="locator" d:isdatasource="true" />     <resourcedictionary.mergeddictionaries></resourcedictionary.mergeddictionaries> </resourcedictionary> 

with this:

<vm:viewmodellocator x:key="locator" d:isdatasource="true" /> 

but haven't bothered why works on wp7 not wp8


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -