无法找到Type local:TextInputToVisibilityConverter

时间:2017-05-14 16:25:05

标签: c# wpf

我正在寻找如何在WPF中创建占位符,我找到了答案here。我在我的文件中使用了XAML代码,它给了我以下错误:The Type local:TextInputToVisibilityConverter Could Not Be Found。这条线看起来像这样:

<local:TextInputToVisibilityConverter x:Key="TextInputToVisibilityConverter" />

我很困惑为什么它会给我这个错误,因为我的c#代码中有TextInputToVisibilityConverter

    public class TextInputToVisibilityConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // Always test MultiValueConverter inputs for non-null
            // (to avoid crash bugs for views in the designer)
            if (values[0] is bool && values[1] is bool)
            {
                bool hasText = !(bool)values[0];
                bool hasFocus = (bool)values[1];

                if (hasFocus || hasText)
                    return Visibility.Collapsed;
            }

            return Visibility.Visible;
        }


        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

非常感谢帮助。

0 个答案:

没有答案