类型" DateToStringConverter"不可访问

时间:2015-01-01 18:08:12

标签: c# xaml visual-studio-2013 intellisense

我在x64 Windows 8.1上运行Visual Studio 2013社区更新4,截至2014年12月30日已应用所有可用更新。我在带有2个处理器和4Gig分配的MacBook Pro上的VMWare Fusion 7上运行Windows 8.1。使用C#,标准Blank模板,并添加我自己的自定义类。我已将命名空间添加到MainPage.xaml:

<Page
    x:Class="BindingWithValueConverters.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BindingWithValueConverters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:valueconverter="using:BindingWithValueConverters.Converters"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    DataContext="{Binding WeatherViewModel, RelativeSource={RelativeSource Self}}">

    <Page.Resources>
        <valueconverter:DateToStringConverter x:Key="DateToStringConverter" />
    </Page.Resources>
    ...

红色波浪形&#34; line仍在&#34; valueconverter下:DateToStringConverter&#34 ;;如果我删除该行,并开始输入,&#34; va ...&#34; Intellisense选择&#34; valueconverter:&#34;,所以命名空间是&#34;那里&#34;。然后,&#34; DateToStringConverter&#34; class显示为自动完成的选项。一旦被接受,在短暂的延迟之后,红色的波浪形状回来指定:

The type "DateToStringConverter" is not accessible.

代码构建并运行,没有错误。我可以盲目地继续编码。但是,解决这个问题是最佳的。非常感谢指导。

我已经清理了这个项目。我删除了* .suo文件。手机模拟器在非VM上运行。我已经在Windows 8.1计算机上运行了这个确切的项目(没有VM),并且没有这个问题。我怀疑是Intellisense。如果有帮助,这是我的转换器类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;

namespace BindingWithValueConverters.Converters
{
    class DateToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            //throw new NotImplementedException();
            DateTime date = (DateTime)value;
            return String.Format("{0:dddd}  -  {0:d}", date);
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}

VMWare / Mac是工作与否之间的明显区别;但是,我希望我的VMWare部署或Visual Studio部署中缺少一个可以解决此问题的Intellisense参数。 Intellisense正在该项目的其他任何地方工作。

谢谢!

1 个答案:

答案 0 :(得分:3)

您的转换器类尚未获得显式访问修饰符。把它公之于众,它会很好地显示出来。

public class DateToStringConverter : IValueConverter