简体   繁体   中英

XAML Converter in different namespace

I'm developing ac# Windows Phone 8.1 App in VC2013 and stumbled over an odd issue.

To make my Code more 'clean', I decided to put different parts of my App into different folders. There is no problem with calling XAML pages from these folders in the c# code.

BUT I seem to have issues linking these folders in XAML Code itself. For example I have following structure:

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

To use the IValueConverter from the converterClass.cs like I always did, I put the following in the Header of my XAML file:

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

Now it happens, that if I type <myConverter: the autocomplete does find my converter classes like usually, but when compiling (it is compiling) and testing on device none of the converters works and also I get an error in the Error-list saying

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

Where did I go wrong?

wow ... after using VS2015 and the same error persisted, I played a little bit around with settings and stuff.

I kept being curious, why it would compile and deploy even it triggered so many errors. The problem appeared to be inconsistent.

The solution was different than expected:

You have to set Solution Platforms to x86 instead of ARM (which I needed to deploy on device). Luckily VS2015 has this option in a handy shortcut, what you can't say about VS2013.

Nevertheless it's solved...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM