Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
See more:
I have been trying to evaluate a Binding within a MarkupExtension ProvideValue class and have been unable to figure out how to accomplish this.

What I have tried:

The dummy converter:

C#
public class DummyConverter : IValueConverter
    {
        public object Value;
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Value = value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }

the code within the ProvideValue method:


C#
if (BindTo != null)
            {
                var dummy = new DummyConverter();
                BindTo.Converter = dummy;
                BindTo.ProvideValue(serviceProvider);
                var value = dummy.Value;
            }
Posted
Updated 5-Mar-18 8:26am
v2
Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900