private void AddTextProperty() { var obj = TextProperty; if (obj == null) { obj = TextProperty = new TextBox(); obj.Style = TC.TextPropertyStyle; obj.KeyDown += TC.TextProperty_KeyDown; obj.LostFocus += TC.TextProperty_LostFocus; obj.GotFocus += TC.TextProperty_GotFocus; obj.DataContext = this; } var txt = PropertyModel.GetTextValue(TC.TCM.Root); obj.Text = txt ?? string.Empty; obj.Tag = obj.Text; obj.IsReadOnly = (Model is PropertyModel pm) && pm.IsReadOnly; StackPanel.Children.Add(obj); }