Windows Phone 8.1 - 转换器无法使用平台目标ARM

Fra*_*Fra 5 c# arm converter winrt-xaml windows-phone-8.1

我在Windows Phone 8.1上开发了应用程序.我的几个页面都有自定义转换器; 例如:

 using System;
 using System.Globalization;
 using Windows.UI.Xaml.Data;

 namespace XXXXX.Model.Converters
 {
     public sealed class DateTimeToStringConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, string language)
         {
             var date = (DateTime)value;

             return date.ToString("g", new CultureInfo("it-IT"));
         }

         public object ConvertBack(object value, Type targetType, object parameter, string language)
         {
             throw new NotImplementedException();
         }
     }
 }
Run Code Online (Sandbox Code Playgroud)

在XAML我有:

 <Page
     x:Class="XXXXX.Views.VehiclesView"
     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:converters="using:XXXXX.Model.Converters"
     mc:Ignorable="d"
     FontFamily="{StaticResource PhoneFontFamilyNormal}"
     Foreground="{StaticResource PhoneForegroundBrush}">

     <Page.Resources>
         <converters:DateTimeToStringConverter x:Key="DateTimeToStringConverter" />
         <converters:StringFormatConverter x:Key="StringFormatConverter" />
     </Page.Resources>
Run Code Online (Sandbox Code Playgroud)

并以这种方式使用它:

 <TextBlock Grid.Row="3" Grid.Column="0" Text="{Binding Distance, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0} Km'}"></TextBlock>
Run Code Online (Sandbox Code Playgroud)

1)为什么编译器会给我这个错误?

 The name "DateTimeToStringConverter" does not exist in the namespace using:XXXXX.Model.Converters
Run Code Online (Sandbox Code Playgroud)

2)如果我将目标平台更改为x86,为什么它可以工作?

3)如果我想在XAML中工作而不是在Code Behind中工作,那么转换器有替代品吗?

Max*_*Max 4

尝试将转换器移动到目标平台“AnyCPU”的专用类库中,并在您的应用程序项目中引用它。