WPF: Trying to add a class to Window.Resources Again
Posted
by
user3952846
on Stack Overflow
See other posts from Stack Overflow
or by user3952846
Published on 2014-08-18T21:03:11Z
Indexed on
2014/08/19
4:21 UTC
Read the original article
Hit count: 143
wpf
I did exactly the same thing, but still the same error is occurring: "The tag 'CenterToolTipConverter' does not exist in XML namespace 'clr-namespace:WpfApplication1;assembly=WpfApplication1'. Line 12 Position 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>
What am I doing wrong? Thanks in advance!!!
© Stack Overflow or respective owner