-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Windows] Fix Picker alignment issues (#13516)
* Fix Windows Picker alignment issues * Refactoring code * Update src/Controls/samples/Controls.Sample/Pages/Controls/PickerPage.xaml.cs Co-authored-by: Manuel de la Pena <mandel@microsoft.com> * Auto-format source code * Fix build errors * Auto-format source code --------- Co-authored-by: Manuel de la Pena <mandel@microsoft.com> Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
- Loading branch information
1 parent
16fcd7e
commit 048ae02
Showing
7 changed files
with
175 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
namespace Microsoft.Maui.Controls | ||
using System; | ||
using Microsoft.Maui.Controls.Platform; | ||
|
||
namespace Microsoft.Maui.Controls | ||
{ | ||
public partial class Picker | ||
{ | ||
public static void MapHorizontalOptions(IPickerHandler handler, Picker picker) | ||
{ | ||
handler.PlatformView?.UpdateHorizontalOptions(picker); | ||
} | ||
|
||
public static void MapVerticalOptions(IPickerHandler handler, Picker picker) | ||
{ | ||
handler.PlatformView?.UpdateVerticalOptions(picker); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Controls/src/Core/Platform/Windows/Extensions/PickerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using Microsoft.UI.Xaml; | ||
|
||
namespace Microsoft.Maui.Controls.Platform | ||
{ | ||
public static class PickerExtensions | ||
{ | ||
public static void UpdateHorizontalOptions(this FrameworkElement platformView, View view) | ||
{ | ||
platformView.HorizontalAlignment = view.HorizontalOptions.Alignment switch | ||
{ | ||
LayoutAlignment.Start => HorizontalAlignment.Left, | ||
LayoutAlignment.Center => HorizontalAlignment.Center, | ||
LayoutAlignment.End => HorizontalAlignment.Right, | ||
LayoutAlignment.Fill => HorizontalAlignment.Stretch, | ||
_ => throw new ArgumentOutOfRangeException() | ||
}; | ||
} | ||
|
||
public static void UpdateVerticalOptions(this FrameworkElement platformView, View view) | ||
{ | ||
platformView.VerticalAlignment = view.VerticalOptions.Alignment switch | ||
{ | ||
LayoutAlignment.Start => VerticalAlignment.Top, | ||
LayoutAlignment.Center => VerticalAlignment.Center, | ||
LayoutAlignment.End => VerticalAlignment.Bottom, | ||
LayoutAlignment.Fill => VerticalAlignment.Stretch, | ||
_ => throw new ArgumentOutOfRangeException() | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters