I'm doing this WPF tutorial and for some reason I get an error when adding a custom SlidersToColorConverter
class to resources.
Someone on StackOverflow was doing it exact same way.
MainWindow.xaml:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication2"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:SlidersToColorConverter x:Key="whyareyounotworking"/>
</Window.Resources>
</Window>
SlidersToColorConverter.cs:
namespace WpfApplication2
{
class SlidersToColorConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double red = (double)values[0];
double green = (double)values[1];
double blue = (double)values[2];
return new SolidColorBrush(Color.FromArgb(255, (byte)red, (byte)green, (byte)blue));
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Error List:
The name "SlidersToColorConverter" does not exist in the namespace "clr-namespace:WpfApplication2". c:\users\mateusz\documents\visual studio 2013\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml 39 9 WpfApplication2
It looks like the class is private (by default). You must change your definition to
public class SlidersToColorConverter : IMultiValueConverter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With