加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

wpf – Setters不在依赖属性上运行?

发布时间:2020-12-14 01:05:24 所属栏目:百科 来源:网络整理
导读:只是一个简短的问题,澄清一些疑问。当元素绑定到依赖属性时,设置器是否不运行? public string TextContent{ get { return (string)GetValue(TextContentProperty); } set { SetValue(TextContentProperty,value); Debug.WriteLine("Setting value of Text
只是一个简短的问题,澄清一些疑问。当元素绑定到依赖属性时,设置器是否不运行?
public string TextContent
{
    get { return (string)GetValue(TextContentProperty); }
    set { SetValue(TextContentProperty,value); Debug.WriteLine("Setting value of TextContent: " + value); }
}

public static readonly DependencyProperty TextContentProperty =
    DependencyProperty.Register("TextContent",typeof(string),typeof(MarkdownEditor),new UIPropertyMetadata(""));

… …

<TextBox Text="{Binding TextContent}" />

正如我注意到下面在我的安装程序不运行

Debug.WriteLine("Setting value of TextContent: " + value);
WPF绑定引擎直接调用GetValue和SetValue(绕过属性设置器和getter)。您需要该属性,以便它可以在XAML标记中支持(并正确编译)。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读