Ver código fonte

Added IsEnabled and Visibility bindings for PanelAction

frogsoftware 1 ano atrás
pai
commit
2815b44ca2
1 arquivos alterados com 26 adições e 0 exclusões
  1. 26 0
      inabox.wpf/Panel/IPanel.cs

+ 26 - 0
inabox.wpf/Panel/IPanel.cs

@@ -4,6 +4,7 @@ using System.ComponentModel;
 using System.Drawing;
 using System.Windows;
 using System.Windows.Controls;
+using ICSharpCode.AvalonEdit;
 using InABox.Configuration;
 using InABox.Core;
 
@@ -17,6 +18,31 @@ public interface IPanelActionItem
 public class PanelAction : DependencyObject, IPanelActionItem
 {
     public Action<PanelAction>? OnExecute { get; set; }
+    
+    public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.Register(
+        nameof(IsEnabled),
+        typeof(bool),
+        typeof(PanelAction),
+        new PropertyMetadata(true)
+    );
+    
+    public bool IsEnabled 
+    { 
+        get => (bool)GetValue(IsEnabledProperty);
+        set => SetValue(IsEnabledProperty, value);
+    }
+    public static readonly DependencyProperty VisibilityProperty = DependencyProperty.Register(
+        nameof(Visibility),
+        typeof(Visibility),
+        typeof(PanelAction),
+        new PropertyMetadata(Visibility.Visible)
+    );
+    
+    public Visibility Visibility 
+    { 
+        get => (Visibility)GetValue(VisibilityProperty);
+        set => SetValue(VisibilityProperty, value);
+    }
 
     public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(
         nameof(Caption),