2013-05-13 18 views
6

MVVM Light paketini NuGet üzerinden eklediğimde, yükleme sırasında eklenen App.xaml dosyasındaki satırlara başvuruda hatalar alıyorum. Bu hatalar sadece Windows Phone 8 projelerinde görünür. Bir Windows Phone 7 projesindeki kesin satırlar, herhangi bir hata oluşturmaz.Hatalar App.xaml Windows Phone 8 projesinde MVVM Işığı kullanmaya çalışıyor Project

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

Bu satırlar sadece biten </Application.Resources> etiket önce konumlandırılmıştır: MVVM Işık çizgilerdir eklendi. Hata Listesi bölmesinde bildirilen hataları şunlardır: :

  • Her Sözlük ilişkili anahtar
  • adı "ViewModelLocator" ad alanında yok "sdkVoiceAlarmClockWP8CS.ViewModel clr-ad" olmalıdır

    Bu, <ResourceDictionary> etiketinin bir anahtar özeliğine sahip olmadığından anlamlı görünmektedir. Ancak, bu satır bloğunu bloğu dışına taşımaya çalışırsam, yeni bir hata kümesi alırım.

    Bildiğim kadarıyla ViewModelLocator sorun, ben iki kere kontrol ettim ve şu ad herhangi bir hata ile bir özellik olarak <Uygulama> etiketi eklenir ve bayrağı atanmamış ilgili olarak:

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

    Bu aynı satırlar neden bir Windows Phone 7 projesinde düzgün çalışıyor ve Windows Phone 8 projemde sahip olduğum ad alanı sorunlarını nasıl düzeltebilirim? Daha önce bu sorunu vardı

    <?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> 
    

cevap

2

: Bu burada daha karmaşık bir sorun nedeniyle olur ne olmaz

tüm App.xaml dosyasıdır.

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

Ama WP7 üzerinde çalışır neden olarak rahatsız değil ama WP8

+1

MVVM Light'ın, NuGet komut dosyalarını güncellemesi gerekiyor gibi görünüyor. –

+0

dostum rock :). –

0

takın herşey içine var: Sadece bu ile

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

: Bu WP8 içinde çalışmasını sağlamak için bu yerine Bu stackoverflow question'da belirtildiği gibi, tüm gerekli ad alanlarıyla ApplicationResources yerine ResourceDictionary.

İlgili konular