Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows Phone 8.1-使用平台目标ARM时转换器不工作_C#_Arm_Winrt Xaml_Converter_Windows Phone 8.1 - Fatal编程技术网

C# Windows Phone 8.1-使用平台目标ARM时转换器不工作

C# Windows Phone 8.1-使用平台目标ARM时转换器不工作,c#,arm,winrt-xaml,converter,windows-phone-8.1,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

我已经在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>
2) 如果我将目标平台更改为x86,为什么它会起作用


3) 如果我想在XAML中工作,而不是在代码隐藏中工作,是否有转换器的替代方案?

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

确保在相同的程序集中尝试转换器,但不使用ConverterParameter和CultureInfo。也只是公共课。清理项目并进行重建。虽然外观上一切正常。你能试着重建吗?@Dmitry Dashko:是的,转换器在同一个组件中@igrali:我多次重建解决方案,但问题仍然存在。您能解释一下为什么它需要在一个单独的库中吗?转换器使用的是Windows.UI.Xaml.Data;在图书馆项目中,此参考不可用或需要添加。这是怎么做到的?请在此提供帮助:)
 <TextBlock Grid.Row="3" Grid.Column="0" Text="{Binding Distance, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0} Km'}"></TextBlock>
 The name "DateTimeToStringConverter" does not exist in the namespace using:XXXXX.Model.Converters