Generic.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using InABox.DynamicGrid;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Input;
  10. namespace InABox.WPF
  11. {
  12. public class ObjectToGridLengthConverter : AbstractConverter<FrameworkElement?, GridLength>
  13. {
  14. public GridLength NotNull { get; set; } = new GridLength(0, GridUnitType.Pixel);
  15. public GridLength IsNull { get; set; } = new GridLength(1, GridUnitType.Auto);
  16. public override GridLength Convert(FrameworkElement? value)
  17. {
  18. return value == null
  19. ? IsNull
  20. : NotNull;
  21. }
  22. }
  23. public class ObjectToVisibilityConverter : AbstractConverter<FrameworkElement?, Visibility>
  24. {
  25. public Visibility NotNull { get; set; } = Visibility.Visible;
  26. public Visibility IsNull { get; set; } = Visibility.Collapsed;
  27. public override Visibility Convert(FrameworkElement? value)
  28. {
  29. return value == null
  30. ? IsNull
  31. : NotNull;
  32. }
  33. }
  34. public partial class Generic : ResourceDictionary
  35. {
  36. public Generic()
  37. {
  38. //InitializeComponent();
  39. }
  40. private void Panel_OnPreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
  41. {
  42. var parent = (sender as FrameworkElement)?.TemplatedParent as DynamicTabItem;
  43. if (parent == null)
  44. return;
  45. parent.ContextMenuCommand.Execute(null);
  46. }
  47. }
  48. }