HideCommandLayoutItemFromLayoutModelConverter.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*************************************************************************************
  2. Extended WPF Toolkit
  3. Copyright (C) 2007-2013 Xceed Software Inc.
  4. This program is provided to you under the terms of the Microsoft Public
  5. License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
  6. For more features, controls, and fast professional support,
  7. pick up the Plus Edition at http://xceed.com/wpf_toolkit
  8. Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
  9. ***********************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Data;
  15. using Xceed.Wpf.AvalonDock.Layout;
  16. using Xceed.Wpf.AvalonDock.Controls;
  17. namespace Xceed.Wpf.AvalonDock.Converters
  18. {
  19. public class HideCommandLayoutItemFromLayoutModelConverter : IValueConverter
  20. {
  21. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  22. {
  23. //when this converter is called layout could be constructing so many properties here are potentially not valid
  24. var layoutModel = value as LayoutContent;
  25. if (layoutModel == null)
  26. return null;
  27. if (layoutModel.Root == null)
  28. return null;
  29. if (layoutModel.Root.Manager == null)
  30. return null;
  31. var layoutItemModel = layoutModel.Root.Manager.GetLayoutItemFromModel(layoutModel) as LayoutAnchorableItem;
  32. if (layoutItemModel == null)
  33. return Binding.DoNothing;
  34. return layoutItemModel.HideCommand;
  35. }
  36. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  37. {
  38. throw new NotImplementedException();
  39. }
  40. }
  41. }