79471788

Date: 2025-02-27 06:46:42
Score: 2
Natty:
Report link

Is there a way to share information between value converters ?

I initially thought about binding all the object and update the property once (I mean the Enum) inside the value converter, but I prefer binding only the property (string) and revaluate the Enum locally, but if I could share it, that's would be great.

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
    var fieldDescriptionPattern = FieldHelpers.GetDescriptionPattern((string)value); // <- Can I share it in multiple value converters : font weight, foreground, etc.?

    if (_fieldDescriptionBrushes.TryGetValue(fieldDescriptionPattern, out Brush brush))
    {
        return brush;
    }

    return Brushes.Transparent;
}
Reasons:
  • Blacklisted phrase (1): Is there a way
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Starts with a question (0.5): Is there a
  • Low reputation (0.5):
Posted by: Ludovic Wagner