2013-05-13 2 views
6

NuGet을 통해 MVVM Light 패키지를 추가 할 때 설치 중에 추가 된 App.xaml 파일의 라인을 참조하는 오류가 발생합니다. 이 오류는 Windows Phone 8 프로젝트에만 나타납니다. Windows Phone 7 프로젝트의 동일한 줄은 오류를 발생시키지 않습니다.Windows Phone 8 프로젝트에서 MVVM Light를 사용하려고하는 App.xaml의 오류

<ResourceDictionary> 
    <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> 
    <ResourceDictionary.MergedDictionaries></ResourceDictionary.MergedDictionaries> 
</ResourceDictionary> 

이 라인은 바로 종료 </Application.Resources> 태그 앞에 위치 다음 MVVM 라이트 라인은 덧붙였다. 오류 목록 창에보고 오류는 다음과 같습니다 :

  • 각 사전이 연관된 키
  • 이름 "ViewModelLocator는"네임 스페이스에 존재하지 않는 "sdkVoiceAlarmClockWP8CS.ViewModel CLR-네임 스페이스를"이 있어야합니다

    <ResourceDictionary> 태그에는 키 속성이 없으므로 의미가있는 것처럼 보입니다. 그러나이 블록 블록을 블록 외부로 이동하려고하면 완전히 새로운 오류 세트가 발생합니다.

    마찬가지로 지금까지 ViewModelLocator 문제는, 내가 두 번 확인하고 다음 네임 스페이스에 오류가있는 속성과 < 응용 프로그램 > 태그에 추가되고이 플래그되지 관한 한 :

    xmlns:vm="clr-namespace:sdkVoiceAlarmClockWP8CS.ViewModel" mc:Ignorable="d" 
    

    Windows Phone 7 프로젝트에서 이와 똑같은 일련의 행이 제대로 작동하는 이유는 무엇이며 어떻게 Windows Phone 8 프로젝트에서 발생하는 네임 스페이스 문제를 해결할 수 있습니까? 내가 전에이 문제를 가지고

    <?xml version="1.0" encoding="utf-8"?> 
    <!-- 
        Copyright (c) 2012 Microsoft Corporation. All rights reserved. 
        Use of this sample source code is subject to the terms of the Microsoft license 
        agreement under which you licensed this sample source code and is provided AS-IS. 
        If you did not accept the terms of the license agreement, you are not authorized 
        to use this sample source code. For the terms of the license, please see the 
        license agreement between you and Microsoft. 
    
        To see all Code Samples for 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 that handles lifetime events for the application--> 
         <shell:PhoneApplicationService Launching="Application_Launching" Closing="Application_Closing" Activated="Application_Activated" Deactivated="Application_Deactivated" /> 
        </Application.ApplicationLifetimeObjects> 
    
    </Application> 
    

답변

2

이 여기에 더 복잡한 문제로 인해 이런 경우에

전체 App.xaml 파일입니다.

<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> 

그러나 나는 그것이 WP7에서 작동 이유에 방해되지하지만 WP8

+1

MVVM Light와 같은 사운드는 NuGet 스크립트를 업데이트해야합니다. –

+0

친구 야 :). –

0

삽입 모두에있다 : 그냥이 함께

<ResourceDictionary> 
    <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> 
    <ResourceDictionary.MergedDictionaries></ResourceDictionary.MergedDictionaries> 
</ResourceDictionary> 

을 : 그것은 WP8에서 작동하게하려면이 교체 이 stackoverflow question에 이미 언급 된 것처럼 필요한 모든 네임 스페이스가있는 ApplicationResources가 아닌 ResourceDictionary.

관련 문제