Browse Source

Image Tooltips on DynamicActionColumns can now have a maximum size

Kenric Nugteren 4 tháng trước cách đây
mục cha
commit
5c64dfa619
1 tập tin đã thay đổi với 15 bổ sung2 xóa
  1. 15 2
      inabox.wpf/DynamicGrid/Columns/DynamicActionColumn.cs

+ 15 - 2
inabox.wpf/DynamicGrid/Columns/DynamicActionColumn.cs

@@ -49,7 +49,7 @@ namespace InABox.DynamicGrid
             return border;
         }
 
-        public FrameworkElement? ImageToolTip(BitmapImage? image)
+        public FrameworkElement? ImageToolTip(BitmapImage? image, double? maxWidth = null, double? maxHeight = null)
         {
             if (image == null)
                 return null;
@@ -60,7 +60,20 @@ namespace InABox.DynamicGrid
                 BorderBrush = new SolidColorBrush(Colors.Gray),
                 BorderThickness = new Thickness(0.75)
             };
-            result.Child = new Image { Source = image };
+            var imageControl = new Image
+            {
+                Source = image,
+                Stretch = Stretch.Uniform
+            };
+            if (maxWidth.HasValue)
+            {
+                imageControl.MaxWidth = maxWidth.Value;
+            }
+            if (maxHeight.HasValue)
+            {
+                imageControl.MaxHeight = maxHeight.Value;
+            }
+            result.Child = imageControl;
             return result;
         }