Click here to Skip to main content
13,446,174 members (36,072 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 7 Jan 2011

Debugging Trick in XAML DataBinding

, 7 Jan 2011
Rate this:
Please Sign up or sign in to vote.
Debugging XAML DataBinding
It is difficult to Debug the XAML data binding in WPF.

As a developer, we always tend to debug our programs when there are problems.

If something goes wrong like:
- No Data display
- Showing some wrong data

You need to debug and see:
- Whether the binding is successful
- Does data object have values
- and so on...

Here is the Trick to Debug the Data Binding of XAML.

All you need to do is create a Converter class.

public class DebugConverter : IValueConverter
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            return value;
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            return value;

While binding the Data to the Control, use the DebugConverter as Converter.

Like, declaring the Converter in XAML:

<conv:DebugConverter x:Key="debugConverter" />

Assigning to the Control whether we need to Debug the DataBinding:

<ListBox ItemsSource="{Binding ElementName=windowObject, Path=CollectionOfString, Converter={StaticResource debugConverter}}"/>

Now place a Breakpoint at the Convert function. That's it.


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


About the Author

Venkatesh Mookkan
Team Leader
Australia Australia
He is from a small village in Tirunelveli, TamilNadu (India). He is fun loving guy. He like to travel a lot. Bikes/Cars/Mobiles are his fantasies.

He started his career as a BPO Data Entry Assistant and got chance to work as an ASP.NET Programmer in the same company after a year. And he move to the next company in 2006 as Software Engineer.

He worked as a Team Leader in a private software development company @Chennai, India for 8+years.

Now working as a Consultant @Sydney, Australia.

You may also be interested in...

Comments and Discussions

GeneralMay be are right. But how many people knew it? Thanks for te... Pin
Venkatesh Mookkan7-Jan-11 13:10
memberVenkatesh Mookkan7-Jan-11 13:10 
GeneralReason for my vote of 1 There is already a built in mechanis... Pin
SledgeHammer017-Jan-11 9:39
memberSledgeHammer017-Jan-11 9:39 
GeneralIf you already using a Converter to do some basic operation,... Pin
Venkatesh Mookkan7-Jan-11 4:22
memberVenkatesh Mookkan7-Jan-11 4:22 
GeneralIt's not always helpful. Atleast, when you have an object of... Pin
Kunal_Chowdhury7-Jan-11 4:17
mvpKunal_Chowdhury7-Jan-11 4:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180314.2 | Last Updated 7 Jan 2011
Article Copyright 2011 by Venkatesh Mookkan
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid