Windows Phone 8.1 -转换器不能使用平台目标ARM

本文关键字:平台 目标 ARM 不能 转换器 Phone Windows | 更新日期: 2023-09-27 18:14:22

我在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();
         }
     }
 }

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

并这样使用:

 <TextBlock Grid.Row="3" Grid.Column="0" Text="{Binding Distance, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0} Km'}"></TextBlock>

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

 The name "DateTimeToStringConverter" does not exist in the namespace using:XXXXX.Model.Converters

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

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

Windows Phone 8.1 -转换器不能使用平台目标ARM

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