簡體   English   中英

不同名稱空間中的XAML轉換器

[英]XAML Converter in different namespace

我正在VC2013中開發ac#Windows Phone 8.1 App,偶然發現了一個奇怪的問題。

為了使我的代碼更“干凈”,我決定將App的不同部分放入不同的文件夾中。 從c#代碼中的這些文件夾中調用XAML頁面沒有問題。

但是我似乎在XAML代碼本身中鏈接這些文件夾時遇到問題。 例如,我具有以下結構:

root, Files: App.cs+xaml, Mainpage.cs+xaml
|
-- Folder: Login
     |
     -- Files: LoginPage.cs+xaml
-- Folder: Converters
     |
     -- Files: converterClass.cs

要像往常一樣使用converterClass.csIValueConverter ,請將以下內容放在XAML文件的標題中:

<Page
 x:Class="myApp.Login.LoginPage"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:local="using:meinStundenplaner.Login"
 xmlns:myConverter="using:myApp.Converters"
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 mc:Ignorable="d"
 Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Page.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="../Styles/standardStyles.xaml"/>
        </ResourceDictionary.MergedDictionaries>

        <myConverter:DateTimeConverter x:Key="DateTimeConverter" />
        ... some more converters

    </ResourceDictionary>
</Page.Resources>
...

現在發生的是,如果我鍵入<myConverter:自動<myConverter:全確實會像通常那樣找到我的轉換器類,但是在編譯(正在編譯)和在設備上進行測試時,所有轉換器都無法正常工作,並且在錯誤列表中顯示錯誤

The name 'DateTimeConverter' in namespace 'using:myApp.Converters' does not exist.

我哪里做錯了?

哇...使用VS2015后,同樣的錯誤仍然存​​在,我在設置和內容方面玩了一些。

我一直很好奇,為什么即使它引發了很多錯誤,它也仍會編譯和部署。 問題似乎不一致。

解決方案與預期不同:

您必須將Solution Platforms設置為x86而不是ARM (我需要在設備上進行部署)。 幸運的是,VS2015在便捷的快捷方式中提供了此選項,您無法對VS2013這么說。

不過解決了...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM