public void SetKeyboardLayoutControl(VirtualKeyboardControl parent, FrameworkElement keyboardLayoutControl) { FrameworkElement oldKeyboardControl = _keyboardLayoutControl; _keyboardLayoutControl = null; if (oldKeyboardControl != null) oldKeyboardControl.CleanupAndDispose(); if (keyboardLayoutControl == null) return; keyboardLayoutControl.Context = parent; keyboardLayoutControl.LogicalParent = this; keyboardLayoutControl.VisualParent = this; keyboardLayoutControl.SetScreen(Screen); keyboardLayoutControl.SetElementState(_elementState); if (IsAllocated) keyboardLayoutControl.Allocate(); _keyboardLayoutControl = keyboardLayoutControl; InvalidateLayout(true, true); }
protected void SetTemplateControl(FrameworkElement templateControl) { FrameworkElement oldTemplateControl = _templateControl; if (ReferenceEquals(oldTemplateControl, templateControl)) return; _templateControl = null; if (oldTemplateControl != null) oldTemplateControl.CleanupAndDispose(); if (templateControl == null) return; object content = _convertedContent; if (!(content is FrameworkElement)) // If our content is a FrameworkElement itself, it should only be used as template control but not as context templateControl.Context = content; templateControl.LogicalParent = this; templateControl.VisualParent = this; templateControl.SetScreen(Screen); templateControl.SetElementState(_elementState); if (IsAllocated) templateControl.Allocate(); _templateControl = templateControl; InvalidateLayout(true, true); }