Why does this work...
<data:DataGridTemplateColumn Header="YTD v. Exchange" x:Name="YTDvExchange" Visibility="Collapsed" CanUserSort="True" SortMemberPath="ytdExchangeReturn.value">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Right" VerticalAlignment="Center"
Text="{Binding ytdExchangeReturn.value, Converter={StaticResource fcFixedDecimalConverter}}"
Foreground="{Binding ytdExchangeReturn.value, Converter={StaticResource fcForegroundValueConverter}}"/>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
But this does not...
<data:DataGridTextColumn Header="YTD v. Exchange"
Binding="{Binding ytdExchangeReturn.value, Converter={StaticResource fcFixedDecimalConverter}}"
Foreground="{Binding ytdExchangeReturn.value, Converter={StaticResource fcForegroundValueConverter}}"/>
I get 'System.Windows.Markup.XamlParseException: AG_E_PARSER_BAD_PROPERTY_VALUE' for the second one. The problem applies ony to the Foreground converter, the binding is fine.
I think the issue is that the Foreground property of the DataGridTextColumn is not a dependency property and hence cannot be used for databinding.
The Foreground property of the TextBlock used for the CellTemplate is a dependency property and hence a valid target for databinding.
http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.foreground(v=vs.95).aspx
Reference:
http://msdn.microsoft.com/en-us/library/cc221408(VS.95).aspx#setting_properties_data_binding
http://forums.silverlight.net/forums/p/151524/338879.aspx#338879