Click here to Skip to main content
12,820,118 members (25,373 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# XAML WPF VS2010 DataGrid , +
I have created a datagrid which displays a Table of records populating from a Database
& would like to animate the cells of the datagrid when certain condition is met.
For this I created a converter class named **BlinkConverter** that inherits IValueConverter.

to put this converter into action, I have mapped the project namespace onto the xaml editor as


Note: BlinkApplication is the name of my Project

After adding this, I am trying to create an instance of my BlinkConvertor class for Binding with Windows.Resources collection as

            <local:BlinkConverter x:key="Blink"></local:BlinkConverter>

here my Intellisense is not detecting the class BlinkCoverter after I type *"local: "* , even if I try to type, I have an error stating "The type local:BlinkConverter was not found. Verify that you are missing an assembly reference and that all referenced assemblies have been built."

Even though I have added the entire project under the xmlns in my xaml editor .
What is wrong here ? have I missed any reference ?
Posted 10-Dec-12 1:55am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

If you have added the converter and have not built the project, you will get that error. Any new classes you add to the project must be built before they will be picked up by the xaml interpreter.

Secondly, make sure you don't have a namespace problem. For example, if you created a behaviors folder and you have the cs file for the behavior in that folder, Visual Studio would have likely put that class at BlinkApplication.Behaviors. Your :local reference will have to match that. Look at the top of the file containing the converter class and see if there is a namespace declaration.

The best thing I've found is to add the code for the converter, build the project, then go into the xaml and add the namespace. Intellisense will pop-up the available ones and you can find it in there. That ensures you've got it declared properly.

Finally, make sure you declared your converter Public. May seem silly but it won't be available in xaml if you don't.
Ind_Pri 10-Dec-12 12:51pm
Do I have to add the Converter class as a part of the MainWindow.xaml.cs class or add a new class naming Converter and then mapping it to the MainWindow.xaml.cs class ?

Because on the first try, I added the as a part of Mainwindow.xaml.cs on the first try, then my Intellisense didn't detect, but when I added a separate class as Converter.cs , my Intellisense detects but I dont know the way to map to my Mainwindow.xaml.cs class :(


public class Converter : IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
string cellvalue = value.ToString();
return cellvalue = ("Pass");
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
return false;


namespace BlinkApplication
public partial class MainWindow : Window
SqlConnection cn;
SqlDataAdapter da;
DataSet ds;
public MainWindow()
DataContext = this;
cn = new SqlConnection(@"Data Source=CZC0239ZWZ\SQLEXPRESS; Initial Catalog =Student; Integrated Security=true");

private void Window_Loaded(object sender, RoutedEventArgs e)
da = new SqlDataAdapter("select * from dbo.View_StudentResults",cn);
ds = new DataSet();


Jason Gleim 10-Dec-12 13:51pm
Your public class Converter is correct... although I wouldn't call it 'Converter'... something less likely to collide with a keyword is probably a better idea... like "myConverter".

So you have MyConverter.cs and in it you have:

namespace BlinkApplication.Converters
public class myConverter:IValueConverter

After you add that to the project (as it seems you have done) build the project. You should build successfully. This adds the class into the project at the correct namespace for the xaml interpreter to find it. If you don't do this, you won't get intellisence in xaml and VS will tell you the class doesn't exist.

In MainWindow.xaml, you'll add the converter namespace at the top..
Notice that it matches the namespace as declared in the Converters.cs file? That associates the "local" tag with the BlinkApplication.Converters namespace.

Once you have done that, you can declare the converter in the page/window/user control resources:
<local:myConverter Key="myValueConverter" />

Finally... use the converter in the code:

<TextBlock Text={Binding someBinding, Converter={StaticResource myValueConverter}} />

You should not do anything in the code behind (MainWindow.xaml.cs). Although you CAN assign this stuff in the code behind, it is meant to be declaratively defined in xaml.
Ind_Pri 11-Dec-12 4:57am
Thanks a lot. It worked finally and I got a better understanding..
Cheers :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Are you using VS2010? I also experience that sometimes, and check what I am actually missing, but I guess VS is experiencing bug. Try to rebuild and ignore the intellisense it will be recognize later on.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100