I'm trying to add a converter to a DataGridTextColumn to convert the foreground brush based on the value of the cell in the xaml file. The DecimalConverter works fine and follows the same pattern.
Here is my xaml...
<UserControl.Resources>
<y:FixedDecimalConverter x:Key="FixedDecimalConverter" />
<y:ForegroundValueConverter x:Key="ForegroundV开发者_高级运维alueConverter" />
</UserControl.Resources>
...
<data:DataGridTextColumn
Header="Absolute Return"
Binding="{Binding totalAbsoluteReturn.value, Converter={StaticResource FixedDecimalConverter}}"
Foreground="{Binding totalAbsoluteReturn.value, Converter={StaticResource ForegroundValueConverter}}" />
Here is the converter...
type ForegroundValueConverter() =
interface IValueConverter with
member this.Convert(value, targetType, parameter, culture) =
let o: obj = upcast new SolidColorBrush(Colors.Red);
o
member this.ConvertBack(value, targetType, parameter, culture) = raise <| NotImplementedException()
...
Here is the error message
Message: Unhandled Error in Silverlight Application Code: 4004
Category: ManagedRuntimeError Message: System.Windows.Markup.XamlParseException: AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 29 Position: 32] at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at Module1.MyIdeas..ctor() at Module1.Template..ctor() at Module1.MyApp..ctor()
Haven't tried it, but the folks oer there claim it works
http://forums.silverlight.net/forums/p/151524/338879.aspx#338879
精彩评论