As mentioned in the header, I am having problems using data binding using DependencyProperty. I have a class called HTMLBox:
public class HTMLBox : RichTextBox { public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(HTMLBox)); public string Text { get { return GetValue(TextProperty) as string; } set { Console.WriteLine("Setter..."); SetValue(TextProperty, value); } } public HTMLBox() {
I am reading a text property in the constructor, so it should appear as text when the string is bound to the property. But even if I bind some data to the Text property in xaml, I donβt even see "Setter ..." - Message, which should be displayed when the Text property is set.
<local:HTMLBox Text="{Binding Text}" Width="{Binding Width}" AcceptsReturn="True" Height="{Binding Height}" />
If I change the HTMLBox in the TextBox, the text displays correctly, so the error is probably in my HTMLBox class. What am I doing wrong?
source share