LayoutDocumentItem.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 Xceed.Wpf.AvalonDock.Layout;
  15. using System.Windows;
  16. namespace Xceed.Wpf.AvalonDock.Controls
  17. {
  18. public class LayoutDocumentItem : LayoutItem
  19. {
  20. LayoutDocument _document;
  21. internal LayoutDocumentItem()
  22. {
  23. }
  24. internal override void Attach(LayoutContent model)
  25. {
  26. _document = model as LayoutDocument;
  27. base.Attach(model);
  28. }
  29. protected override void Close()
  30. {
  31. var dockingManager = _document.Root.Manager;
  32. dockingManager._ExecuteCloseCommand(_document);
  33. }
  34. #region Description
  35. /// <summary>
  36. /// Description Dependency Property
  37. /// </summary>
  38. public static readonly DependencyProperty DescriptionProperty =
  39. DependencyProperty.Register("Description", typeof(string), typeof(LayoutDocumentItem),
  40. new FrameworkPropertyMetadata((string)null,
  41. new PropertyChangedCallback(OnDescriptionChanged)));
  42. /// <summary>
  43. /// Gets or sets the Description property. This dependency property
  44. /// indicates the description to display for the document item.
  45. /// </summary>
  46. public string Description
  47. {
  48. get { return (string)GetValue(DescriptionProperty); }
  49. set { SetValue(DescriptionProperty, value); }
  50. }
  51. /// <summary>
  52. /// Handles changes to the Description property.
  53. /// </summary>
  54. private static void OnDescriptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  55. {
  56. ((LayoutDocumentItem)d).OnDescriptionChanged(e);
  57. }
  58. /// <summary>
  59. /// Provides derived classes an opportunity to handle changes to the Description property.
  60. /// </summary>
  61. protected virtual void OnDescriptionChanged(DependencyPropertyChangedEventArgs e)
  62. {
  63. _document.Description = (string)e.NewValue;
  64. }
  65. #endregion
  66. internal override void Detach()
  67. {
  68. _document = null;
  69. base.Detach();
  70. }
  71. }
  72. }