Click here to Skip to main content
15,394,560 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using VS2017
WPF application
.Net Framework 4.72


I've got a converter that I added to a xaml file, but the xaml designer is telling me this:

The name "BoolToColorConverter" does not exist in the namespace "clr-namespace:WpfCommon.Converters;assembly=WpfCommon"

As you can see by the code below, it DOES exist in the namespace. Furthermore, I have other converters declared - IN THE SAME NAMESPACE - and they don't show any errors.

I live in the designer, and this problem is preventing the markup from being displayed.

Despite all of the above, the app compiles and runs fine, and the converter does what it's supposed to do.

using System;
using System.Windows.Data;
using System.Windows.Media;

namespace WpfCommon.Converters
	public class BoolToColorConverter : IValueConverter
		public string ValueIfFalse { get; set; }
		public string ValueIfTrue  { get; set; }

		public BoolToColorConverter()
			ValueIfFalse = "Red";
			ValueIfTrue  = "Green";

		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
			bool condition = (bool)value;
			string colorName = (condition) ? this.ValueIfTrue : this.ValueIfFalse;
			SolidColorBrush brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString((string)colorName));
			return brush;

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
			throw new NotImplementedException();

Added the obligatory definition in my XAML:

<wpfctrls:WizardPageBase x:Class="EntityFactory.WizardPages.WizPgSettings2"

		<converters:BoolToColorConverter x:Key="BoolColorConverter" ValueIfTrue="Red" ValueIfFalse="SteelBlue"/>

And added it to the appropriate property in the control:

<Button Background="{Binding Path=AppSettings.IsModified,Converter={StaticResource BoolColorConverter}}" />

What I have tried:

I've tried rebuilding the WpfCommon assembly on its own.and moving the declaration up and down the list of other declared converters.
Updated 4-Nov-21 0:39am

1 solution

I decided to try shutting down Visual Studio, and starting it back up, and that cleared up the error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900