private static UIElement GetUIElementChecked(ObjectHolder element)
 {
     var uiElement = element.Value as UIElement;
     if (uiElement == null)
         throw new InvalidOperationException(Resources.Message_UIElement_is_not_valid);
     return uiElement;
 }
 public void RemoveUIElement(ObjectHolder element)
 {
     var uiElement = GetUIElementChecked(element);
     if(_stackPanel.Children.Contains(uiElement))
         _stackPanel.Children.Remove(uiElement);
 }
 public void AddUIElement(ObjectHolder element)
 {
     var uiElement = GetUIElementChecked(element);
     if (!_stackPanel.Children.Contains(uiElement))
         _stackPanel.Children.Add(uiElement);
 }