Generic.cs 1.6 KB

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