Friday, November 27, 2009

WPF form and debugging data

I never realized just how painful it can be to debug data that should (or should not) display on a XAML form.  I bound a XAML form to a DataSet.  There was a problem with one of the columns in the dataset that caused problems with the XAML form.  But since there is no way to step through the debugger on the XAML, there was no way to figure out what the specific data was that was giving me problems.
 
The problem was solved through a Converter.  I discovered you can put a breakpoint on a converter, then view your data.  In my case, I had no need of a converter, so couldn't set up a breakpoint.
 
The solution was to add a special converter.  This one did not do any actual conversion--it simply returned the passed value.  But it gave me a simple way to put a breakpoint.
 
Below is the converter code:

class LogObjectDataConverter : 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;
}

No comments:

Post a Comment