ClipGrid.cs 836 B

1234567891011121314151617181920212223242526272829
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Media;
  4. using HandyControl.Data;
  5. namespace HandyControl.Controls
  6. {
  7. public class ClipGrid : Grid
  8. {
  9. public static readonly DependencyProperty IsClipEnabledProperty = DependencyProperty.Register(
  10. nameof(IsClipEnabled), typeof(bool), typeof(ClipGrid), new PropertyMetadata(ValueBoxes.TrueBox));
  11. public bool IsClipEnabled
  12. {
  13. get => (bool) GetValue(IsClipEnabledProperty);
  14. set => SetValue(IsClipEnabledProperty, ValueBoxes.BooleanBox(value));
  15. }
  16. protected override Geometry GetLayoutClip(Size layoutSlotSize)
  17. {
  18. if (IsClipEnabled)
  19. {
  20. return base.GetLayoutClip(layoutSlotSize);
  21. }
  22. return null;
  23. }
  24. }
  25. }