There is a problem with setting DataBinding as a Header in Column (e.g. DataGridTextColumn) from Silverlight Client SDK. Unfortunately Header is not a dependency property, do binding to it will result in converting DataBinding to string (calling its ToString() method).
“System.Windows.Data.Binding”
To overcome the problem create a helper with a Dependency property (e.g. HeaderBinding). Change to HeaderBinding binding should set the real Header string.
Usage:
<sdk:DataGridTextColumn Controls:DataGridColumnHelper.HeaderBinding="{Binding Something” />
Helper:
public static class DataGridColumnHelper
{
public static readonly DependencyProperty HeaderBindingProperty = DependencyProperty.RegisterAttached(
"HeaderBinding",
typeof(object),
typeof(DataGridColumnHelper),
new PropertyMetadata(null, DataGridColumnHelper.HeaderBinding_PropertyChanged));
public static object GetHeaderBinding(DependencyObject source)
{
return (object)source.GetValue(DataGridColumnHelper.HeaderBindingProperty);
}
public static void SetHeaderBinding(DependencyObject target, object value)
{
target.SetValue(DataGridColumnHelper.HeaderBindingProperty, value);
}
private static void HeaderBinding_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
DataGridColumn column = d as DataGridColumn;
if (column == null) { return; }
column.Header = e.NewValue;
}
}