public PropertyContainer(string propertyName, ValueControl valueControl, FrameworkElement inactiveElement) { this.propertyName = propertyName; this.activeElement = valueControl; this.inactiveElement = inactiveElement; //Add three columns ColumnDefinitions.Add(new ColumnDefinition() { }); ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(150), SharedSizeGroup = "PropGridColumn" }); //Create wrappers keyWrapper = new Border() { Name = "keywrapper", Background = new SolidColorBrush(Colors.White) }; valueWrapper = new Border() { Name = "valuewrapper", Background = new SolidColorBrush(Colors.White) }; Grid.SetColumn(keyWrapper, 0); Grid.SetColumn(valueWrapper, 1); this.Children.Add(keyWrapper); this.Children.Add(valueWrapper); textLabel = new TextBlock(); textLabel.TextTrimming = TextTrimming.CharacterEllipsis; textLabel.ToolTip = propertyName; textLabel.Text = propertyName; keyWrapper.Child = textLabel; //If we only have one element (e.g textblock or something, we set the child to this) //if we have both an active element and an inactive (E.G textbox for editing and textblock when inactive) //set the child to the inactive element if (inactiveElement == null) { valueWrapper.Child = valueControl.Control; } else { //Attach click listeners to the active element //we do this to not loose focus on the element //if the mouse moves outside this property containers bounds while editing it valueWrapper.Child = inactiveElement; //valueControl.Control.GotKeyboardFocus += ValueControl_GotKeyboardFocus; } this.Focusable = true; }
public PropertyContainer(string propertyName, ValueControl valueControl) : this(propertyName, valueControl, null) { }