DropDownControlArea.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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;
  15. using System.Windows.Controls;
  16. using System.Windows.Controls.Primitives;
  17. using System.Windows.Media;
  18. using System.Windows.Input;
  19. using System.Diagnostics;
  20. namespace Xceed.Wpf.AvalonDock.Controls
  21. {
  22. public class DropDownControlArea : UserControl
  23. {
  24. //static DropDownControlArea()
  25. //{
  26. // //IsHitTestVisibleProperty.OverrideMetadata(typeof(DropDownControlArea), new FrameworkPropertyMetadata(true));
  27. //}
  28. public DropDownControlArea()
  29. {
  30. }
  31. #region DropDownContextMenu
  32. /// <summary>
  33. /// DropDownContextMenu Dependency Property
  34. /// </summary>
  35. public static readonly DependencyProperty DropDownContextMenuProperty =
  36. DependencyProperty.Register("DropDownContextMenu", typeof(ContextMenu), typeof(DropDownControlArea),
  37. new FrameworkPropertyMetadata((ContextMenu)null));
  38. /// <summary>
  39. /// Gets or sets the DropDownContextMenu property. This dependency property
  40. /// indicates context menu to show when a right click is detected over the area occpied by the control.
  41. /// </summary>
  42. public ContextMenu DropDownContextMenu
  43. {
  44. get { return (ContextMenu)GetValue(DropDownContextMenuProperty); }
  45. set { SetValue(DropDownContextMenuProperty, value); }
  46. }
  47. #endregion
  48. #region DropDownContextMenuDataContext
  49. /// <summary>
  50. /// DropDownContextMenuDataContext Dependency Property
  51. /// </summary>
  52. public static readonly DependencyProperty DropDownContextMenuDataContextProperty =
  53. DependencyProperty.Register("DropDownContextMenuDataContext", typeof(object), typeof(DropDownControlArea),
  54. new FrameworkPropertyMetadata((object)null));
  55. /// <summary>
  56. /// Gets or sets the DropDownContextMenuDataContext property. This dependency property
  57. /// indicates data context to attach when context menu is shown.
  58. /// </summary>
  59. public object DropDownContextMenuDataContext
  60. {
  61. get { return (object)GetValue(DropDownContextMenuDataContextProperty); }
  62. set { SetValue(DropDownContextMenuDataContextProperty, value); }
  63. }
  64. #endregion
  65. protected override void OnMouseRightButtonDown(System.Windows.Input.MouseButtonEventArgs e)
  66. {
  67. base.OnMouseRightButtonDown(e);
  68. }
  69. protected override void OnPreviewMouseRightButtonUp(System.Windows.Input.MouseButtonEventArgs e)
  70. {
  71. base.OnPreviewMouseRightButtonUp(e);
  72. if (!e.Handled)
  73. {
  74. if (DropDownContextMenu != null)
  75. {
  76. DropDownContextMenu.PlacementTarget = null;
  77. DropDownContextMenu.Placement = PlacementMode.MousePoint;
  78. DropDownContextMenu.DataContext = DropDownContextMenuDataContext;
  79. DropDownContextMenu.IsOpen = true;
  80. // e.Handled = true;
  81. }
  82. }
  83. }
  84. //protected override System.Windows.Media.HitTestResult HitTestCore(System.Windows.Media.PointHitTestParameters hitTestParameters)
  85. //{
  86. // var hitResult = base.HitTestCore(hitTestParameters);
  87. // if (hitResult == null)
  88. // return new PointHitTestResult(this, hitTestParameters.HitPoint);
  89. // return hitResult;
  90. //}
  91. }
  92. }