maui-linux/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issu.../Bugzilla27417.cs

81 строка
2.6 KiB
C#
Исходник Обычный вид История

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 27417,
"Button.Image behaviors differently on each platform and has extra padding even with no Text", PlatformAffected.All)]
public class Bugzilla27417 : TestContentPage
{
protected override void Init()
{
var instructions = new Label { Text = @"There should be 8 buttons below (the bottom 7 are in a ScrollView).
Buttons 1 and 2 have images which are horizontally and vertically centered.
Button 3 should have the text 'Click Me' in the center.
Button 4 should have an image in the center and no text.
Button 5 should have the image on the left and the text on the right.
Button 6 should have the image on the top and the text on the bottom.
Button 7 should have the image on the bottom and the text on the top.
Button 8 have the image on the right and the text on the left." };
var grid = new Grid
{
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition { Height = 100 }
},
VerticalOptions = LayoutOptions.Start,
Children =
{
new Button
{
HeightRequest = 500, // Making sure that the image still gets centered vertically even if the HeightRequest won't be honored
[WIP] Unify the image handling (#4915) * Initial code to get unifiied image handling - not yet tested - still using FileImageSource in some areas * Updated the button renderers and added tests for Android * Updated a few more of the Android renderers - also added an `IsEmpty` property to the ImageSource to indicate if this source actually contains data that can be used to try and load an image - added a few more "tests" - includes the changes for #4916 * A few more changes * Keep the default page for the sample app * Changing everything to ImageSource and going from there - Android, iOS, UWP and WPF are compiling - GTK, Mac and Tizen are not yet finished - Added a new interface for UWP to return an IconElement in addition to ImageSource (for app bar buttons) - not tested yet, nor are there any tests * Renamed the property to be more useful * All of Android is now async - still only minimal tests - also removed the bits that are in https://github.com/xamarin/Xamarin.Forms/pull/4948 * Update Xamarin.Forms.Platform.cs * A few fixes to whitespace and nameof() * Updated iOS and UWP wirth async image sources * A few fixes and WPF support * A few fixes for Android after the big merge * Updated a few more loaders: - ios - macos - tizen - gtk * Fix a few things after the merge * - cast type to FileImageSource * fix setting of title content if icon doesn't load * fix IButtonLayoutManager to return correct control * remove cast and add pack api * - fix timing issues with layout/invalidation * - remove aggresive element invalidations for now * first set of api changes * obsolete old apis and create new ones for ImageSource * obsolete messages and static ordering fix * add tests * switch default on windows to show images on tabs * - XStatic obsolete fix * fix NPC test and bring back alert check on uwp Fixes #3207 Fixes #4689
2019-04-26 23:46:13 +03:00
ImageSource = "coffee.png"
}
}
};
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Fill,
Spacing = 10,
Children =
{
instructions,
grid,
new ScrollView
{
Content = new StackLayout
{
Spacing = 10,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
[WIP] Unify the image handling (#4915) * Initial code to get unifiied image handling - not yet tested - still using FileImageSource in some areas * Updated the button renderers and added tests for Android * Updated a few more of the Android renderers - also added an `IsEmpty` property to the ImageSource to indicate if this source actually contains data that can be used to try and load an image - added a few more "tests" - includes the changes for #4916 * A few more changes * Keep the default page for the sample app * Changing everything to ImageSource and going from there - Android, iOS, UWP and WPF are compiling - GTK, Mac and Tizen are not yet finished - Added a new interface for UWP to return an IconElement in addition to ImageSource (for app bar buttons) - not tested yet, nor are there any tests * Renamed the property to be more useful * All of Android is now async - still only minimal tests - also removed the bits that are in https://github.com/xamarin/Xamarin.Forms/pull/4948 * Update Xamarin.Forms.Platform.cs * A few fixes to whitespace and nameof() * Updated iOS and UWP wirth async image sources * A few fixes and WPF support * A few fixes for Android after the big merge * Updated a few more loaders: - ios - macos - tizen - gtk * Fix a few things after the merge * - cast type to FileImageSource * fix setting of title content if icon doesn't load * fix IButtonLayoutManager to return correct control * remove cast and add pack api * - fix timing issues with layout/invalidation * - remove aggresive element invalidations for now * first set of api changes * obsolete old apis and create new ones for ImageSource * obsolete messages and static ordering fix * add tests * switch default on windows to show images on tabs * - XStatic obsolete fix * fix NPC test and bring back alert check on uwp Fixes #3207 Fixes #4689
2019-04-26 23:46:13 +03:00
new Button { WidthRequest = 200, HeightRequest = 300, ImageSource = "coffee.png" },
new Button { Text = "Click Me", BackgroundColor = Color.Gray },
[WIP] Unify the image handling (#4915) * Initial code to get unifiied image handling - not yet tested - still using FileImageSource in some areas * Updated the button renderers and added tests for Android * Updated a few more of the Android renderers - also added an `IsEmpty` property to the ImageSource to indicate if this source actually contains data that can be used to try and load an image - added a few more "tests" - includes the changes for #4916 * A few more changes * Keep the default page for the sample app * Changing everything to ImageSource and going from there - Android, iOS, UWP and WPF are compiling - GTK, Mac and Tizen are not yet finished - Added a new interface for UWP to return an IconElement in addition to ImageSource (for app bar buttons) - not tested yet, nor are there any tests * Renamed the property to be more useful * All of Android is now async - still only minimal tests - also removed the bits that are in https://github.com/xamarin/Xamarin.Forms/pull/4948 * Update Xamarin.Forms.Platform.cs * A few fixes to whitespace and nameof() * Updated iOS and UWP wirth async image sources * A few fixes and WPF support * A few fixes for Android after the big merge * Updated a few more loaders: - ios - macos - tizen - gtk * Fix a few things after the merge * - cast type to FileImageSource * fix setting of title content if icon doesn't load * fix IButtonLayoutManager to return correct control * remove cast and add pack api * - fix timing issues with layout/invalidation * - remove aggresive element invalidations for now * first set of api changes * obsolete old apis and create new ones for ImageSource * obsolete messages and static ordering fix * add tests * switch default on windows to show images on tabs * - XStatic obsolete fix * fix NPC test and bring back alert check on uwp Fixes #3207 Fixes #4689
2019-04-26 23:46:13 +03:00
new Button { ImageSource = "coffee.png", BackgroundColor = Color.Gray },
CreateButton(new Button.ButtonContentLayout(Button.ButtonContentLayout.ImagePosition.Left, 10)),
CreateButton(new Button.ButtonContentLayout(Button.ButtonContentLayout.ImagePosition.Top, 10)),
CreateButton(new Button.ButtonContentLayout(Button.ButtonContentLayout.ImagePosition.Bottom, 10)),
CreateButton(new Button.ButtonContentLayout(Button.ButtonContentLayout.ImagePosition.Right, 10))
}
}
}
}
};
}
static Button CreateButton(Button.ButtonContentLayout layout)
{
return new Button
{
Text = "Click Me",
[WIP] Unify the image handling (#4915) * Initial code to get unifiied image handling - not yet tested - still using FileImageSource in some areas * Updated the button renderers and added tests for Android * Updated a few more of the Android renderers - also added an `IsEmpty` property to the ImageSource to indicate if this source actually contains data that can be used to try and load an image - added a few more "tests" - includes the changes for #4916 * A few more changes * Keep the default page for the sample app * Changing everything to ImageSource and going from there - Android, iOS, UWP and WPF are compiling - GTK, Mac and Tizen are not yet finished - Added a new interface for UWP to return an IconElement in addition to ImageSource (for app bar buttons) - not tested yet, nor are there any tests * Renamed the property to be more useful * All of Android is now async - still only minimal tests - also removed the bits that are in https://github.com/xamarin/Xamarin.Forms/pull/4948 * Update Xamarin.Forms.Platform.cs * A few fixes to whitespace and nameof() * Updated iOS and UWP wirth async image sources * A few fixes and WPF support * A few fixes for Android after the big merge * Updated a few more loaders: - ios - macos - tizen - gtk * Fix a few things after the merge * - cast type to FileImageSource * fix setting of title content if icon doesn't load * fix IButtonLayoutManager to return correct control * remove cast and add pack api * - fix timing issues with layout/invalidation * - remove aggresive element invalidations for now * first set of api changes * obsolete old apis and create new ones for ImageSource * obsolete messages and static ordering fix * add tests * switch default on windows to show images on tabs * - XStatic obsolete fix * fix NPC test and bring back alert check on uwp Fixes #3207 Fixes #4689
2019-04-26 23:46:13 +03:00
ImageSource = "coffee.png",
ContentLayout = layout,
BackgroundColor = Color.Gray
};
}
}
}