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

标签 c# arm winrt-xaml converter 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();
         }
     }
 }

在我的 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 而不是代码隐藏中工作,是否有转换器的替代方案?

最佳答案

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

关于c# - Windows Phone 8.1 - 转换器无法使用平台目标 ARM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24920065/

相关文章:

c# - Android 插件 UnitySendMessage 从未被调用

c# - 如何覆盖 ContentControlThemeFontFamily

c# Thread不会将Row添加到DataGridView CrossThreadError

c# - 问题 SpeechSynthesizer.SetOutputToAudioStream 音频格式问题

c# - 什么是 HTTP Referer header ?

arm - 如何使用 NEON 比较(大于或等于)指令?

c - 如何测量 ARM Cortex-A8 处理器中的程序执行时间?

assembly - ARM 组装难题

windows-8 - Windows 应用商店应用程序 : How to draw a dashed line?

c# - WinRT FlipView.SelectedIndex 绑定(bind)不响应 ViewModel 中的更改