Implemented Padding on WPF Button (#6791)
* Implemented Padding on WPF Button * Update Padding when BorderWidth is updated * Implemented Padding for ImageButton * Apply suggestions from code review Co-Authored-By: Pavel Yakovlev <v-payako@microsoft.com> fixes #6790
This commit is contained in:
Родитель
80a050dfe3
Коммит
630eb65516
|
@ -94,6 +94,15 @@ namespace Xamarin.Forms.Controls
|
|||
}
|
||||
);
|
||||
|
||||
var paddingContainer = new ViewContainer<ImageButton>(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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -570,7 +570,8 @@ namespace Xamarin.Forms.CustomAttributes
|
|||
Clicked,
|
||||
Command,
|
||||
Image,
|
||||
Pressed
|
||||
Pressed,
|
||||
Padding
|
||||
}
|
||||
|
||||
public enum ImageSource
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче