只是一个简短的问题,澄清一些疑问。当元素绑定到依赖属性时,设置器是否不运行?
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标记中支持(并正确编译)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。