diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/ImageButtonCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/ImageButtonCoreGalleryPage.cs index 0b51bf59e..0dec344c2 100644 --- a/Xamarin.Forms.Controls/CoreGalleryPages/ImageButtonCoreGalleryPage.cs +++ b/Xamarin.Forms.Controls/CoreGalleryPages/ImageButtonCoreGalleryPage.cs @@ -94,6 +94,15 @@ namespace Xamarin.Forms.Controls } ); + var paddingContainer = new ViewContainer(Test.ImageButton.Padding, + new ImageButton + { + Source = "oasissmall.jpg", + BackgroundColor = Color.Red, + Padding = new Thickness(20, 30, 60, 15) + } + ); + InitializeElement(aspectFillContainer.View); InitializeElement(aspectFitContainer.View); @@ -117,6 +126,7 @@ namespace Xamarin.Forms.Controls Add(corderRadiusContainer); Add(imageContainer); Add(pressedContainer); + Add(paddingContainer); } } } \ No newline at end of file diff --git a/Xamarin.Forms.CustomAttributes/TestAttributes.cs b/Xamarin.Forms.CustomAttributes/TestAttributes.cs index c609b42cb..7e7d9f1b7 100644 --- a/Xamarin.Forms.CustomAttributes/TestAttributes.cs +++ b/Xamarin.Forms.CustomAttributes/TestAttributes.cs @@ -570,7 +570,8 @@ namespace Xamarin.Forms.CustomAttributes Clicked, Command, Image, - Pressed + Pressed, + Padding } public enum ImageSource diff --git a/Xamarin.Forms.Platform.WPF/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.WPF/Renderers/ButtonRenderer.cs index 9c6ab1ce6..20b8b7154 100644 --- a/Xamarin.Forms.Platform.WPF/Renderers/ButtonRenderer.cs +++ b/Xamarin.Forms.Platform.WPF/Renderers/ButtonRenderer.cs @@ -36,6 +36,9 @@ namespace Xamarin.Forms.Platform.WPF if (Element.BorderWidth != 0) UpdateBorderWidth(); + if (Element.IsSet(Button.PaddingProperty)) + UpdatePadding(); + UpdateFont(); } @@ -55,7 +58,12 @@ namespace Xamarin.Forms.Platform.WPF else if (e.PropertyName == Button.BorderColorProperty.PropertyName) UpdateBorderColor(); else if (e.PropertyName == Button.BorderWidthProperty.PropertyName) + { UpdateBorderWidth(); + UpdatePadding(); + } + else if (e.PropertyName == Button.PaddingProperty.PropertyName) + UpdatePadding(); } void HandleButtonClick(object sender, RoutedEventArgs e) @@ -185,5 +193,15 @@ namespace Xamarin.Forms.Platform.WPF _isDisposed = true; base.Dispose(disposing); } + + void UpdatePadding() + { + Control.Padding = new WThickness( + Element.Padding.Left, + Element.Padding.Top, + Element.Padding.Right, + Element.Padding.Bottom + ); + } } -} \ No newline at end of file +} diff --git a/Xamarin.Forms.Platform.WPF/Renderers/ImageButtonRenderer.cs b/Xamarin.Forms.Platform.WPF/Renderers/ImageButtonRenderer.cs index 03a4335aa..1beda9ad6 100644 --- a/Xamarin.Forms.Platform.WPF/Renderers/ImageButtonRenderer.cs +++ b/Xamarin.Forms.Platform.WPF/Renderers/ImageButtonRenderer.cs @@ -55,6 +55,9 @@ namespace Xamarin.Forms.Platform.WPF await TryUpdateSource().ConfigureAwait(false); UpdateAspect(); + + if (Element.IsSet(Button.PaddingProperty)) + UpdatePadding(); } } @@ -67,9 +70,14 @@ namespace Xamarin.Forms.Platform.WPF else if (e.PropertyName == ImageButton.BorderColorProperty.PropertyName) UpdateBorderColor(); else if (e.PropertyName == ImageButton.BorderWidthProperty.PropertyName) + { UpdateBorderWidth(); + UpdatePadding(); + } else if (e.PropertyName == ImageButton.AspectProperty.PropertyName) UpdateAspect(); + else if (e.PropertyName == Button.PaddingProperty.PropertyName) + UpdatePadding(); } protected override void Dispose(bool disposing) @@ -190,5 +198,15 @@ namespace Xamarin.Forms.Platform.WPF Control.VerticalAlignment = System.Windows.VerticalAlignment.Top; } } + + void UpdatePadding() + { + Control.Padding = new WThickness( + Element.Padding.Left, + Element.Padding.Top, + Element.Padding.Right, + Element.Padding.Bottom + ); + } } }