Ver Fonte

Fixed UI of filter button

Kenric Nugteren há 5 meses atrás
pai
commit
5c5dcdd4f5
1 ficheiros alterados com 15 adições e 16 exclusões
  1. 15 16
      inabox.wpf/Forms/FilterButton.cs

+ 15 - 16
inabox.wpf/Forms/FilterButton.cs

@@ -61,6 +61,7 @@ public class FilterButton<T> : Button
         SetValue(BorderBrushProperty, new SolidColorBrush(Colors.Gray));
         SetValue(BorderThicknessProperty, new Thickness(0.75));
         Height = 30;
+        Padding = new(2);
 
         Update(Wpf.Resources.filter, "");
     }
@@ -72,37 +73,35 @@ public class FilterButton<T> : Button
 
     private void Update(System.Drawing.Bitmap image, string text)
     {
-        var stackPnl = new StackPanel();
-        stackPnl.Orientation = Orientation.Horizontal;
-        //stackPnl.Margin = new Thickness(2);
-
-        if (image != null)
+        var img = new Image
         {
-            var img = new Image
-            {
-                Source = image.AsBitmapImage(),
-                Margin = new Thickness(2)
-            };
-            stackPnl.Children.Add(img);
-        }
+            Source = image.AsBitmapImage(),
+            Margin = new()
+        };
 
         if (!string.IsNullOrEmpty(text))
         {
+            var stackPnl = new StackPanel();
+            stackPnl.Orientation = Orientation.Horizontal;
+            //stackPnl.Margin = new Thickness(2);
+
             stackPnl.MaxWidth = double.MaxValue;
             var lbl = new Label();
             lbl.Content = text;
             lbl.VerticalAlignment = VerticalAlignment.Stretch;
             lbl.VerticalContentAlignment = VerticalAlignment.Center;
-            lbl.Margin = new Thickness(2, 0, 5, 0);
+            lbl.Margin = new Thickness(2, 0, 0, 0);
             lbl.ToolTip = ToolTip;
+
+            stackPnl.Children.Add(img);
             stackPnl.Children.Add(lbl);
+
+            Content = stackPnl;
         }
         else
         {
-            stackPnl.MaxWidth = 30;
+            Content = img;
         }
-
-        Content = stackPnl;
     }
 
     protected override void OnClick()