Question

Puis-je utiliser des liaisons avec des extensions de balisage SL5 RC?

Voici mon xaml:

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

Et le moi:

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();
        }
    }

Tester la propriété de mon moi n'est pas réglé via la liaison quoi qu'il arrive, je fais quelque chose de mal?

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top