Just a short question, to clarify some doubts. Are setters not run when an element is bound to a dependency property?
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}" />
As I noticed the below in my setter does not run
Debug.WriteLine("Setting value of TextContent: " + value);
The WPF binding engine calls GetValue
and SetValue
directly (bypassing the property setters and getters). You need the property to be there so it can be supported in the XAML markup (and compile correctly).