我可以将绑定与 SL5 RC 标记扩展一起使用吗?
这是我的 XAML:
...
<TextBlock>
<TextBlock.Text>
<local:LengtherMarkupExtension Test="{Binding ElementName='MyTextBox', Path='Text'}" />
</TextBlock.Text>
</TextBlock>
...
我:
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();
}
}
无论如何,我的 ME 的测试属性都不会通过绑定设置,我做错了吗?