将windows.ui.xaml.Data添加到VS2013 Project

时间:2017-01-18 12:00:33

标签: c# wpf xaml visual-studio-2013 ivalueconverter

我要使用I ivalueconverter接口, 但是此接口位于命名空间下 windows.ui.xaml.Data

我使用Visual Studio 2013 但我不知道如何将此命名空间添加到项目中。 我将progrect定义为WPF应用程序。 并希望添加此类

感谢任何帮助过的人。

1 个答案:

答案 0 :(得分:0)

IValueConverter位于WPF中PresentationFramework.dll的 System.Windows.Data 命名空间中。

在针对Windows 10设备的通用Windows平台(UWP)应用程序中,它仅存在于Windows.UI.Xaml.Data命名空间中。但是这不适用于Visual Studio 2013和WPF,所以试试这个:

public class MyConverter : System.Windows.Data.IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        //conversion logic...
        return value;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotSupportedException();
    }
}