我做了完全相同的事情,但仍然出现相同的错误:“在XML命名空间“clr-namespace:WpfApplication1;assembly=WpfApplication1”中不存在标记“CenterToolTipConverter”。第12行第10个位置。”
CenterToolTipConverter.cs
我做错了什么?提前感谢您!
namespace WpfApplication1
{
public class CenterToolTipConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.FirstOrDefault(v => v == DependencyProperty.UnsetValue) != null)
{
return double.NaN;
}
double placementTargetWidth = (double)values[0];
double toolTipWidth = (double)values[1];
return (placementTargetWidth / 2.0) - (toolTipWidth / 2.0);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
MainWindow.xaml
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1;assembly=WpfApplication1"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:CenterToolTipConverter x:Key="myCenterToolTipConverter"/>
</Window.Resources>
</Window>
我做错了什么?提前感谢您!
xmlns:local="clr-namespace:WpfApplication1"
。 - clcto