Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Using a TestValueConverter to Understand a Bound Object

0.00/5 (No votes)
21 Nov 2015 1  
Using a breakpoint in this WPF Value Converter which basically does nothing can be of assistance in binding when the object is not well understood.

Introduction

I have had many cases when I have worked with third party controls from companies such as Infragistics and Telerik, and have wanted to create some functionality, and have not known enough about the objects I am using to be able to do it. These objects can be extremely complex, which actually can be very good since there is a lot of data that can be tapped to accomplish some special functionality. This also makes them difficult to understand, and there is little on the internet about them. Since these controls are not visible in the normal debugger, I have bound a value to a simple IValueConverter and inserted a breakpoint in the converter so that I could investigate the data that I am bound to. This has allowed to then refine the binding, and create the functionality I need. I have also used this converter when I did not understand why the binding was not working correctly.

The Code

#region using statements

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

#endregion

public sealed class TestConverter : MarkupExtension, IValueConverter
{
    public TestConverter() { }

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return value;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return value;
    }

    public override object ProvideValue(IServiceProvider serviceProvider) { return this; }
}

History

  • 11/21/2015 Initial version

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here