Question

Can I use bindings with SL5 RC Markup Extensions?

Here's my XAML:

...
    <TextBlock>
                <TextBlock.Text>
                   <local:LengtherMarkupExtension Test="{Binding ElementName='MyTextBox', Path='Text'}" />
                </TextBlock.Text>
            </TextBlock>
...

And the ME:

public class LengtherMarkupExtension: FrameworkElement,
        IMarkupExtension<string>
    {
        public LengtherMarkupExtension()
        {
            //this.DataContext = this;
        }


        public static readonly DependencyProperty TestProperty =
            DependencyProperty.Register("Test",
                typeof(string),
                typeof(LengtherMarkupExtension),
                new PropertyMetadata("DefaultValue",
                    (o, e) => 
                    {
                        System.Diagnostics.Debugger.Break();
                    }));


        public string Test
        {
            get { return (string)this.GetValue(LengtherMarkupExtension.TestProperty); }
            set { this.SetValue(LengtherMarkupExtension.TestProperty, value); }
        }


        public string ProvideValue(IServiceProvider serviceProvider)
        {
            return this.Test.Length.ToString();
        }
    }

Test property of my ME doesn't get set via binding no matter what, am I doing something wrong?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top