static void TextPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { InfoTextBox itb = (InfoTextBox)sender; bool actuallyHasText = itb.Text.Length > 0; if (actuallyHasText != itb.HasText) { itb.SetValue(HasTextPropertyKey, actuallyHasText); } }