diff --git a/src/Compatibility/ControlGallery/src/Core/GalleryPages/ButtonGallery.cs b/src/Compatibility/ControlGallery/src/Core/GalleryPages/ButtonGallery.cs index c0a99209c411..9744e12a1ca1 100644 --- a/src/Compatibility/ControlGallery/src/Core/GalleryPages/ButtonGallery.cs +++ b/src/Compatibility/ControlGallery/src/Core/GalleryPages/ButtonGallery.cs @@ -42,7 +42,7 @@ public ButtonGallery() case Device.Android: fontName = "sans-serif-light"; break; - case Device.UWP: + case Device.WinUI: fontName = "Comic Sans MS"; break; } diff --git a/src/Compatibility/ControlGallery/src/Core/GalleryPages/CellsGalleries/ProductViewCell.cs b/src/Compatibility/ControlGallery/src/Core/GalleryPages/CellsGalleries/ProductViewCell.cs index 84315b4fd1f5..275c13256122 100644 --- a/src/Compatibility/ControlGallery/src/Core/GalleryPages/CellsGalleries/ProductViewCell.cs +++ b/src/Compatibility/ControlGallery/src/Core/GalleryPages/CellsGalleries/ProductViewCell.cs @@ -22,7 +22,7 @@ public ProductCellView(string text) var frame = new Frame { Content = _stack, - BackgroundColor = new[] { Device.Android, Device.UWP }.Contains(Device.RuntimePlatform) ? new Color(0.2f) : new Color(1) + BackgroundColor = new[] { Device.Android, Device.WinUI }.Contains(Device.RuntimePlatform) ? new Color(0.2f) : new Color(1) }; _timeLabel = new Label { diff --git a/src/Compatibility/ControlGallery/src/Core/GalleryPages/ImageSourcesGallery.cs b/src/Compatibility/ControlGallery/src/Core/GalleryPages/ImageSourcesGallery.cs index a337ec98b564..b94561606f01 100644 --- a/src/Compatibility/ControlGallery/src/Core/GalleryPages/ImageSourcesGallery.cs +++ b/src/Compatibility/ControlGallery/src/Core/GalleryPages/ImageSourcesGallery.cs @@ -57,7 +57,7 @@ static Picker CreateImageSourcePicker(string title, Action> on case Device.iOS: fontFamily = "Ionicons"; break; - case Device.UWP: + case Device.WinUI: fontFamily = "Assets/Fonts/ionicons.ttf#ionicons"; break; case Device.Android: diff --git a/src/Compatibility/ControlGallery/src/Core/GalleryPages/LabelGallery.cs b/src/Compatibility/ControlGallery/src/Core/GalleryPages/LabelGallery.cs index 4dab7703501c..f7f462a201d8 100644 --- a/src/Compatibility/ControlGallery/src/Core/GalleryPages/LabelGallery.cs +++ b/src/Compatibility/ControlGallery/src/Core/GalleryPages/LabelGallery.cs @@ -88,7 +88,7 @@ public LabelGallery() case Device.Android: fontName = "sans-serif-light"; break; - case Device.UWP: + case Device.WinUI: fontName = "Comic Sans MS"; break; } diff --git a/src/Compatibility/ControlGallery/src/Core/GalleryPages/SwipeViewGalleries/CustomSwipeItemGallery.cs b/src/Compatibility/ControlGallery/src/Core/GalleryPages/SwipeViewGalleries/CustomSwipeItemGallery.cs index b7c0e4c86ee2..244623cc31be 100644 --- a/src/Compatibility/ControlGallery/src/Core/GalleryPages/SwipeViewGalleries/CustomSwipeItemGallery.cs +++ b/src/Compatibility/ControlGallery/src/Core/GalleryPages/SwipeViewGalleries/CustomSwipeItemGallery.cs @@ -17,7 +17,7 @@ public CustomSwipeItemGallery() } }; - if (Device.RuntimePlatform != Device.UWP) + if (Device.RuntimePlatform != Device.WinUI) { layout.Children.Add(GalleryBuilder.NavButton("SwipeItemView Gallery", () => new CustomSwipeItemViewGallery(), Navigation)); layout.Children.Add(GalleryBuilder.NavButton("CustomSwipeItem Size Gallery", () => new CustomSizeSwipeViewGallery(), Navigation)); diff --git a/src/Compatibility/ControlGallery/src/Core/TestCases.cs b/src/Compatibility/ControlGallery/src/Core/TestCases.cs index 8037515e78d8..f2f7379503f9 100644 --- a/src/Compatibility/ControlGallery/src/Core/TestCases.cs +++ b/src/Compatibility/ControlGallery/src/Core/TestCases.cs @@ -363,7 +363,7 @@ public static NavigationPage GetTestCases() default: page.Title = "Test Cases"; break; - case Device.UWP: + case Device.WinUI: page.Title = "Tests"; break; } diff --git a/src/Compatibility/ControlGallery/src/Core/XamStore/StoreShell.xaml.cs b/src/Compatibility/ControlGallery/src/Core/XamStore/StoreShell.xaml.cs index 3098977e416a..ae8c05560d7d 100644 --- a/src/Compatibility/ControlGallery/src/Core/XamStore/StoreShell.xaml.cs +++ b/src/Compatibility/ControlGallery/src/Core/XamStore/StoreShell.xaml.cs @@ -23,7 +23,7 @@ protected override void Init() case Device.iOS: fontFamily = "Ionicons"; break; - case Device.UWP: + case Device.WinUI: fontFamily = "Assets/Fonts/ionicons.ttf#ionicons"; break; case Device.Android: diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla22229.xaml.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla22229.xaml.cs index c81c06881833..40bdbebb21fd 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla22229.xaml.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla22229.xaml.cs @@ -30,7 +30,7 @@ public Bugzilla22229() case Device.Android: _prefix = ""; break; - case Device.UWP: + case Device.WinUI: _prefix = "Assets/"; break; } diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1683.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1683.cs index d7450022233d..26c3de76a77f 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1683.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1683.cs @@ -42,7 +42,7 @@ protected override void Init() KeyboardFlags spellCheckForUwp = KeyboardFlags.None; - if (DeviceInfo.Platform == DevicePlatform.UWP) + if (DeviceInfo.Platform == DevicePlatform.WinUI) { spellCheckForUwp = KeyboardFlags.Spellcheck; } @@ -63,12 +63,12 @@ protected override void Init() inputViews.Add(new EntryKeyboardFlags() { ClassId = "CustomRendererCapitalizeSentence", FlagsToSet = KeyboardFlags.CapitalizeSentence, FlagsToTestFor = KeyboardFlags.CapitalizeSentence }); inputViews.Add(new EntryKeyboardFlags() { ClassId = "CustomRendererCapitalizeWord", FlagsToSet = KeyboardFlags.CapitalizeWord, FlagsToTestFor = KeyboardFlags.CapitalizeWord }); - if (Device.RuntimePlatform != Device.UWP) + if (Device.RuntimePlatform != Device.WinUI) { inputViews.Add(new EntryKeyboardFlags() { ClassId = "CustomRendererCapitalizeCharacter", FlagsToSet = KeyboardFlags.CapitalizeCharacter }); } - if (DeviceInfo.Platform == DevicePlatform.UWP) + if (DeviceInfo.Platform == DevicePlatform.WinUI) { layout.Children.Add(new Label() { Text = "Capitalization settings only work when using touch keyboard" }); layout.Children.Add(new Label() { Text = "Character doesn't do anything on UWP" }); diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1705_2.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1705_2.cs index 75bdb27ea734..7371a5d27f4c 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1705_2.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1705_2.cs @@ -43,7 +43,7 @@ public Issue1705_2() Children.Add(_page2); Children.Add(_page3); - if (DeviceInfo.Platform == DevicePlatform.UWP) + if (DeviceInfo.Platform == DevicePlatform.WinUI) Children.Add(new HeaderIconsControlPage(this) { Title = "UWPSpecifics" }); } } diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2482.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2482.cs index 5a0fc3a08bc5..a126f9109f95 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2482.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2482.cs @@ -94,7 +94,7 @@ protected override void Init() layout.Children.Add(_result); layout.Children.Add(button); - if (DeviceInfo.Platform == DevicePlatform.UWP) + if (DeviceInfo.Platform == DevicePlatform.WinUI) layout.Children.Add(new Label { Text = "\xE76E", FontFamily = "Segoe MDL2 Assets", FontSize = 32 }); Content = layout; diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3343.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3343.cs index 840a9795d149..3a04e47867cd 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3343.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3343.cs @@ -43,7 +43,7 @@ protected override void Init() entry2Label2.SetBinding(Label.TextProperty, new Binding(nameof(Entry.SelectionLength), stringFormat: "SelectionLength: {0}", source: entry2)); // When the Entry is in a NavPage, the Entry doesn't get first focus on UWP - string uwp_instructions = DeviceInfo.Platform == DevicePlatform.UWP ? "Press Tab to focus the first entry. " : ""; + string uwp_instructions = DeviceInfo.Platform == DevicePlatform.WinUI ? "Press Tab to focus the first entry. " : ""; Content = new StackLayout() { diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5132.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5132.cs index 1563941ed7ea..c3f4c0066063 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5132.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5132.cs @@ -51,7 +51,7 @@ static string DefaultFontFamily() case Device.iOS: fontFamily = "Ionicons"; break; - case Device.UWP: + case Device.WinUI: fontFamily = "Assets/Fonts/ionicons.ttf#ionicons"; break; case Device.Android: diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue6491.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue6491.cs index 3e77dd517c9c..4d422dc6d698 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue6491.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue6491.cs @@ -35,7 +35,7 @@ protected override void Init() FontFamily = "FontAwesome5Free-Solid" }; - if (DeviceInfo.Platform == DevicePlatform.UWP) + if (DeviceInfo.Platform == DevicePlatform.WinUI) ((FontImageSource)button.ImageSource).FontFamily = "Assets/Fonts/fa-solid-900.ttf#Font Awesome 5 Free"; stack.Children.Add(label); diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue773.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue773.cs index 1c732cf5454a..d54be883e976 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue773.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue773.cs @@ -119,7 +119,7 @@ public CannotScrollRepro() { BackgroundColor = Colors.Aqua, Orientation = ScrollOrientation.Horizontal, - HeightRequest = DeviceInfo.Platform == DevicePlatform.UWP ? 80 : 44, + HeightRequest = DeviceInfo.Platform == DevicePlatform.WinUI ? 80 : 44, Content = buttonStack }); diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue8801.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue8801.cs index fd1b0e230bd2..a2e817ad9f43 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue8801.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue8801.cs @@ -111,7 +111,7 @@ public PopupStackLayout() HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, Orientation = this.Orientation, - WidthRequest = DeviceInfo.Platform == DevicePlatform.UWP ? 20 : 50, + WidthRequest = DeviceInfo.Platform == DevicePlatform.WinUI ? 20 : 50, }; this.SetBinding(HeightRequestProperty, new Binding(nameof(Height), BindingMode.OneWay, source: showButton)); diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CarouselViewGalleries/CarouselItemsGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CarouselViewGalleries/CarouselItemsGallery.cs index 5f76d354fc95..820e7e538002 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CarouselViewGalleries/CarouselItemsGallery.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CarouselViewGalleries/CarouselItemsGallery.cs @@ -202,7 +202,7 @@ static string DefaultFontFamily() var fontFamily = ""; if (DeviceInfo.Platform == DevicePlatform.iOS) fontFamily = "Ionicons"; - else if (DeviceInfo.Platform == DevicePlatform.UWP) + else if (DeviceInfo.Platform == DevicePlatform.WinUI) fontFamily = "Assets/Fonts/ionicons.ttf#ionicons"; else fontFamily = "fonts/ionicons.ttf#"; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ExampleTemplates.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ExampleTemplates.cs index 084540958112..19fe8b61f095 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ExampleTemplates.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ExampleTemplates.cs @@ -550,7 +550,7 @@ static string DefaultFontFamily() var fontFamily = ""; if (DeviceInfo.Platform == DevicePlatform.iOS) fontFamily = "Ionicons"; - else if (DeviceInfo.Platform == DevicePlatform.UWP) + else if (DeviceInfo.Platform == DevicePlatform.WinUI) fontFamily = "Assets/Fonts/ionicons.ttf#ionicons"; else fontFamily = "fonts/ionicons.ttf#"; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ReorderingGalleries/GroupedReorderingGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ReorderingGalleries/GroupedReorderingGallery.cs index f89c80be8570..5a9687a172a8 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ReorderingGalleries/GroupedReorderingGallery.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ReorderingGalleries/GroupedReorderingGallery.cs @@ -34,7 +34,7 @@ public GroupedReorderingGallery(IItemsLayout itemsLayout) Text = "Reordering of grouped sources is not supported on Windows!", FontSize = 24, FontAttributes = FontAttributes.Bold, - IsVisible = (DeviceInfo.Platform == DevicePlatform.UWP), + IsVisible = (DeviceInfo.Platform == DevicePlatform.WinUI), BackgroundColor = Colors.Red }; diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ReorderingGalleries/UngroupedReorderingGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ReorderingGalleries/UngroupedReorderingGallery.cs index 6a9110a34ee7..1f34d1cee624 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ReorderingGalleries/UngroupedReorderingGallery.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/ReorderingGalleries/UngroupedReorderingGallery.cs @@ -78,7 +78,7 @@ async void UpdateItemsSourceType(ItemsSourceGenerator generator, ItemsSourceType { generator.GenerateItems(itemsSourceType); - if (DeviceInfo.Platform == DevicePlatform.UWP && !(collectionView.ItemsSource is INotifyCollectionChanged)) + if (DeviceInfo.Platform == DevicePlatform.WinUI && !(collectionView.ItemsSource is INotifyCollectionChanged)) { await DisplayAlert("Warning!", "Reordering on UWP/WinUI only works with ObservableCollections!", "OK"); } diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/CustomSwipeItemGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/CustomSwipeItemGallery.cs index edcfe188cd02..c5a1e3f2ca93 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/CustomSwipeItemGallery.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/CustomSwipeItemGallery.cs @@ -19,7 +19,7 @@ public CustomSwipeItemGallery() } }; - if (DeviceInfo.Platform != DevicePlatform.UWP) + if (DeviceInfo.Platform != DevicePlatform.WinUI) { layout.Children.Add(GalleryBuilder.NavButton("SwipeItemView Gallery", () => new CustomSwipeItemViewGallery(), Navigation)); layout.Children.Add(GalleryBuilder.NavButton("CustomSwipeItem Size Gallery", () => new CustomSizeSwipeViewGallery(), Navigation)); diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemIconGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemIconGallery.cs index b15735529266..b1266e4508b7 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemIconGallery.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/SwipeItemIconGallery.cs @@ -146,7 +146,7 @@ static string DefaultFontFamily() var fontFamily = ""; if (DeviceInfo.Platform == DevicePlatform.iOS) fontFamily = "Ionicons"; - else if (DeviceInfo.Platform == DevicePlatform.UWP) + else if (DeviceInfo.Platform == DevicePlatform.WinUI) fontFamily = "Assets/Fonts/ionicons.ttf#ionicons"; else fontFamily = "fonts/ionicons.ttf#"; diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/DevicePage.xaml b/src/Controls/samples/Controls.Sample/Pages/Core/DevicePage.xaml new file mode 100644 index 000000000000..100afe24f6e5 --- /dev/null +++ b/src/Controls/samples/Controls.Sample/Pages/Core/DevicePage.xaml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/DevicePage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/DevicePage.xaml.cs new file mode 100644 index 000000000000..805371071979 --- /dev/null +++ b/src/Controls/samples/Controls.Sample/Pages/Core/DevicePage.xaml.cs @@ -0,0 +1,10 @@ +namespace Maui.Controls.Sample.Pages +{ + public partial class DevicePage + { + public DevicePage() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/Controls/samples/Controls.Sample/Pages/MainPage.xaml b/src/Controls/samples/Controls.Sample/Pages/MainPage.xaml index b7aa97b2cddc..c788f016b7fe 100644 --- a/src/Controls/samples/Controls.Sample/Pages/MainPage.xaml +++ b/src/Controls/samples/Controls.Sample/Pages/MainPage.xaml @@ -51,7 +51,7 @@ - - \ No newline at end of file diff --git a/src/Controls/samples/Controls.Sample/ViewModels/CoreViewModel.cs b/src/Controls/samples/Controls.Sample/ViewModels/CoreViewModel.cs index a045512594d0..99faab58d46d 100644 --- a/src/Controls/samples/Controls.Sample/ViewModels/CoreViewModel.cs +++ b/src/Controls/samples/Controls.Sample/ViewModels/CoreViewModel.cs @@ -26,7 +26,10 @@ public class CoreViewModel : BaseGalleryViewModel new SectionModel(typeof(ClipPage), "Clip", "Defines the outline of the contents of an element."), - + + new SectionModel(typeof(DevicePage), "Device", + "A number of properties and methods to help developers customize layout and functionality on a per-platform basis"), + new SectionModel(typeof(DispatcherPage), "Dispatcher", "Managing UI thread access with dispatchers and timers."), diff --git a/src/Controls/src/Core/Device.cs b/src/Controls/src/Core/Device.cs index 7004b0527fdb..d8ceae7aad8f 100644 --- a/src/Controls/src/Core/Device.cs +++ b/src/Controls/src/Core/Device.cs @@ -24,20 +24,22 @@ public static class Device [Obsolete("Use Essentials.DevicePlatform.Android instead.")] public const string Android = "Android"; /// - [Obsolete("Use Essentials.DevicePlatform.UWP instead.")] - public const string UWP = "UWP"; + [Obsolete("Use Essentials.DevicePlatform.WinUI instead.")] + public const string UWP = "WinUI"; /// [Obsolete("Use Essentials.DevicePlatform.macOS instead.")] - public const string macOS = "macOS"; + internal const string macOS = "macOS"; /// [Obsolete("Use Essentials.DevicePlatform.GTK instead.")] - public const string GTK = "GTK"; + internal const string GTK = "GTK"; /// [Obsolete("Use Essentials.DevicePlatform.Tizen instead.")] public const string Tizen = "Tizen"; + [Obsolete("Use Essentials.DevicePlatform.WinUI instead.")] + public const string WinUI = "WinUI"; /// [Obsolete("Use Essentials.DevicePlatform.WPF instead.")] - public const string WPF = "WPF"; + internal const string WPF = "WPF"; [Obsolete("Use Essentials.DevicePlatform.MacCatalyst instead.")] public const string MacCatalyst = "MacCatalyst"; [Obsolete("Use Essentials.DevicePlatform.tvOS instead.")] diff --git a/src/Controls/src/Core/DeviceStateTrigger.cs b/src/Controls/src/Core/DeviceStateTrigger.cs index 6585d7bc2ec2..401d5d760841 100644 --- a/src/Controls/src/Core/DeviceStateTrigger.cs +++ b/src/Controls/src/Core/DeviceStateTrigger.cs @@ -35,8 +35,8 @@ void UpdateState() SetActive(DeviceInfo.Platform == DevicePlatform.Android); else if (device == DevicePlatform.iOS) SetActive(DeviceInfo.Platform == DevicePlatform.iOS); - else if (device == DevicePlatform.UWP) - SetActive(DeviceInfo.Platform == DevicePlatform.UWP); + else if (device == DevicePlatform.WinUI || device == DevicePlatform.Create("UWP")) + SetActive(DeviceInfo.Platform == DevicePlatform.WinUI); } } } \ No newline at end of file diff --git a/src/Controls/src/Core/OnPlatform.cs b/src/Controls/src/Core/OnPlatform.cs index 34720bdea2d1..9bd436cfa3f9 100644 --- a/src/Controls/src/Core/OnPlatform.cs +++ b/src/Controls/src/Core/OnPlatform.cs @@ -32,15 +32,23 @@ public T Default public static implicit operator T(OnPlatform onPlatform) { - foreach (var onPlat in onPlatform.Platforms) + if (s_valueConverter != null) { - if (onPlat.Platform == null) - continue; - if (!onPlat.Platform.Contains(DeviceInfo.Platform.ToString())) - continue; - if (s_valueConverter == null) - continue; - return (T)s_valueConverter.Convert(onPlat.Value, typeof(T), null, null); + foreach (var onPlat in onPlatform.Platforms) + { + if (onPlat.Platform == null) + continue; + if (!onPlat.Platform.Contains(DeviceInfo.Platform.ToString())) + continue; + return (T)s_valueConverter.Convert(onPlat.Value, typeof(T), null, null); + } + + // fallback for UWP + foreach (var onPlat in onPlatform.Platforms) + { + if (onPlat.Platform != null && onPlat.Platform.Contains("UWP") && DeviceInfo.Platform == DevicePlatform.WinUI) + return (T)s_valueConverter.Convert(onPlat.Value, typeof(T), null, null); + } } return onPlatform.hasDefault ? onPlatform.@default : default(T); diff --git a/src/Controls/src/Core/Shell/BaseShellItem.cs b/src/Controls/src/Core/Shell/BaseShellItem.cs index 2af17a64648d..c01a622aa973 100644 --- a/src/Controls/src/Core/Shell/BaseShellItem.cs +++ b/src/Controls/src/Core/Shell/BaseShellItem.cs @@ -304,7 +304,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str return new DataTemplate(() => { var grid = new Grid(); - if (DeviceInfo.Platform == DevicePlatform.UWP) + if (DeviceInfo.Platform == DevicePlatform.WinUI) grid.ColumnSpacing = grid.RowSpacing = 0; grid.Resources = new ResourceDictionary(); @@ -343,7 +343,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str var selectedState = new VisualState(); selectedState.Name = "Selected"; - if (DeviceInfo.Platform != DevicePlatform.UWP) + if (DeviceInfo.Platform != DevicePlatform.WinUI) { selectedState.Setters.Add(new Setter { @@ -375,7 +375,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str columnDefinitions.Add(new ColumnDefinition { Width = 54 }); else if (DeviceInfo.Platform == DevicePlatform.iOS) columnDefinitions.Add(new ColumnDefinition { Width = 50 }); - else if (DeviceInfo.Platform == DevicePlatform.UWP) + else if (DeviceInfo.Platform == DevicePlatform.WinUI) columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); @@ -388,7 +388,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str sizeRequest = 24; else if (DeviceInfo.Platform == DevicePlatform.iOS) sizeRequest = 22; - else if (DeviceInfo.Platform == DevicePlatform.UWP) + else if (DeviceInfo.Platform == DevicePlatform.WinUI) sizeRequest = 16; if (sizeRequest > 0) @@ -397,7 +397,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str defaultImageClass.Setters.Add(new Setter() { Property = Image.WidthRequestProperty, Value = sizeRequest }); } - if (DeviceInfo.Platform == DevicePlatform.UWP) + if (DeviceInfo.Platform == DevicePlatform.WinUI) { defaultImageClass.Setters.Add(new Setter { Property = Image.HorizontalOptionsProperty, Value = LayoutOptions.Start }); defaultImageClass.Setters.Add(new Setter { Property = Image.MarginProperty, Value = new Thickness(12, 0, 12, 0) }); @@ -437,7 +437,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str defaultLabelClass.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, label) }); defaultLabelClass.Setters.Add(new Setter { Property = Label.FontAttributesProperty, Value = FontAttributes.Bold }); } - else if (DeviceInfo.Platform == DevicePlatform.UWP) + else if (DeviceInfo.Platform == DevicePlatform.WinUI) { defaultLabelClass.Setters.Add(new Setter { Property = Label.HorizontalOptionsProperty, Value = LayoutOptions.Start }); defaultLabelClass.Setters.Add(new Setter { Property = Label.HorizontalTextAlignmentProperty, Value = TextAlignment.Start }); diff --git a/src/Controls/src/Xaml/MarkupExtensions/OnPlatformExtension.cs b/src/Controls/src/Xaml/MarkupExtensions/OnPlatformExtension.cs index c63dc9547229..0d81892cc6ff 100644 --- a/src/Controls/src/Xaml/MarkupExtensions/OnPlatformExtension.cs +++ b/src/Controls/src/Xaml/MarkupExtensions/OnPlatformExtension.cs @@ -13,13 +13,15 @@ public class OnPlatformExtension : IMarkupExtension public object Default { get; set; } = s_notset; public object Android { get; set; } = s_notset; - public object GTK { get; set; } = s_notset; + internal object GTK { get; set; } = s_notset; public object iOS { get; set; } = s_notset; - public object macOS { get; set; } = s_notset; + internal object macOS { get; set; } = s_notset; public object MacCatalyst { get; set; } = s_notset; public object Tizen { get; set; } = s_notset; + [Obsolete("Use WinUI instead.")] public object UWP { get; set; } = s_notset; - public object WPF { get; set; } = s_notset; + internal object WPF { get; set; } = s_notset; + public object WinUI { get; set; } = s_notset; public IValueConverter Converter { get; set; } @@ -33,8 +35,11 @@ public object ProvideValue(IServiceProvider serviceProvider) && macOS == s_notset && MacCatalyst == s_notset && Tizen == s_notset +#pragma warning disable CS0618 // Type or member is obsolete && UWP == s_notset +#pragma warning restore CS0618 // Type or member is obsolete && WPF == s_notset + && WinUI == s_notset && Default == s_notset) { throw new XamlParseException("OnPlatformExtension requires a value to be specified for at least one platform or Default.", serviceProvider); @@ -138,11 +143,23 @@ bool TryGetValueForPlatform(out object value) value = Tizen; return true; } - if (DeviceInfo.Platform == DevicePlatform.UWP && UWP != s_notset) + if (DeviceInfo.Platform == DevicePlatform.WinUI && WinUI != s_notset) + { + value = WinUI; + return true; + } +#pragma warning disable CS0618 // Type or member is obsolete + if (DeviceInfo.Platform == DevicePlatform.WinUI && UWP != s_notset) + { + value = UWP; + return true; + } + if (DeviceInfo.Platform == DevicePlatform.Create("UWP") && UWP != s_notset) { value = UWP; return true; } +#pragma warning restore CS0618 // Type or member is obsolete if (DeviceInfo.Platform == DevicePlatform.Create("WPF") && WPF != s_notset) { value = WPF; diff --git a/src/Controls/src/Xaml/XamlParser.cs b/src/Controls/src/Xaml/XamlParser.cs index 03bd73e7f497..3f91ad6ad5d1 100644 --- a/src/Controls/src/Xaml/XamlParser.cs +++ b/src/Controls/src/Xaml/XamlParser.cs @@ -298,7 +298,7 @@ static IList PrefixesToIgnore(IList> xmlns) if (targetPlatform != DeviceInfo.Platform.ToString()) { // Special case for Windows backward compatibility - if (targetPlatform == "Windows" && DeviceInfo.Platform == DevicePlatform.UWP) + if (targetPlatform == "Windows" && DeviceInfo.Platform == DevicePlatform.WinUI) continue; prefixes.Add(prefix); diff --git a/src/Controls/tests/Xaml.UnitTests/MarkupExpressionParserTests.cs b/src/Controls/tests/Xaml.UnitTests/MarkupExpressionParserTests.cs index 0a4c984613c9..f245e50bb65c 100644 --- a/src/Controls/tests/Xaml.UnitTests/MarkupExpressionParserTests.cs +++ b/src/Controls/tests/Xaml.UnitTests/MarkupExpressionParserTests.cs @@ -351,17 +351,17 @@ public void BindingWithStaticConverter() [TestCase("{OnPlatform 20, Android=23}", "Android", 23)] [TestCase("{OnPlatform Android=20, iOS=25}", "iOS", 25)] - [TestCase("{OnPlatform Android=20, GTK=25}", "GTK", 25)] - [TestCase("{OnPlatform Android=20, macOS=25}", "macOS", 25)] + [TestCase("{OnPlatform Android=20, MacCatalyst=25}", "MacCatalyst", 25)] [TestCase("{OnPlatform Android=20, Tizen=25}", "Tizen", 25)] + [TestCase("{OnPlatform Android=20, WinUI=25}", "WinUI", 25)] + [TestCase("{OnPlatform Android=20, UWP=25}", "WinUI", 25)] + [TestCase("{OnPlatform Android=20, WinUI=25, UWP=20}", "WinUI", 25)] [TestCase("{OnPlatform Android=20, UWP=25}", "UWP", 25)] - [TestCase("{OnPlatform Android=20, WPF=25}", "WPF", 25)] + [TestCase("{OnPlatform 20}", "Android", 20)] [TestCase("{OnPlatform 20}", "iOS", 20)] - [TestCase("{OnPlatform 20}", "GTK", 20)] - [TestCase("{OnPlatform 20}", "macOS", 20)] [TestCase("{OnPlatform 20}", "Tizen", 20)] + [TestCase("{OnPlatform 20}", "WinUI", 20)] [TestCase("{OnPlatform 20}", "UWP", 20)] - [TestCase("{OnPlatform 20}", "WPF", 20)] [TestCase("{OnPlatform 20}", "Foo", 20)] [TestCase("{OnPlatform Android=23, Default=20}", "Foo", 20)] public void OnPlatformExtension(string markup, string platform, int expected) diff --git a/src/Controls/tests/Xaml.UnitTests/OnPlatformTests.cs b/src/Controls/tests/Xaml.UnitTests/OnPlatformTests.cs index 03c0b1fff7d4..036c187cc675 100644 --- a/src/Controls/tests/Xaml.UnitTests/OnPlatformTests.cs +++ b/src/Controls/tests/Xaml.UnitTests/OnPlatformTests.cs @@ -94,6 +94,51 @@ public void TypeConverterAndDerivedTypes() image = new Image().LoadFromXaml(xaml); Assert.AreEqual("icon_twitter.png", (image.Source as FileImageSource).File); } + + [Test] + public void UWPisWinUI() + { + var xaml = @" + + + + icon_twitter.png + icon_twitter.png + Images/icon_twitter.png + + + "; + + Image image; + + mockDeviceInfo.Platform = DevicePlatform.WinUI; + image = new Image().LoadFromXaml(xaml); + Assert.AreEqual("Images/icon_twitter.png", (image.Source as FileImageSource).File); + } + + [Test] + public void ChecksPreferWinUI() + { + var xaml = @" + + + + icon_twitter.png + icon_twitter.png + Images/icon_twitter.png + Images/icon_twitter_preferred.png + + + "; + + Image image; + + mockDeviceInfo.Platform = DevicePlatform.WinUI; + image = new Image().LoadFromXaml(xaml); + Assert.AreEqual("Images/icon_twitter_preferred.png", (image.Source as FileImageSource).File); + } } [TestFixture] diff --git a/src/Essentials/samples/Samples/ViewModel/FilePickerViewModel.cs b/src/Essentials/samples/Samples/ViewModel/FilePickerViewModel.cs index 41661fa4fa0e..f65a27b81ecd 100644 --- a/src/Essentials/samples/Samples/ViewModel/FilePickerViewModel.cs +++ b/src/Essentials/samples/Samples/ViewModel/FilePickerViewModel.cs @@ -90,7 +90,7 @@ async void DoPickCustomType() { { DevicePlatform.iOS, new[] { "public.my.comic.extension" } }, // or general UTType values { DevicePlatform.Android, new[] { "application/comics" } }, - { DevicePlatform.UWP, new[] { ".cbr", ".cbz" } }, + { DevicePlatform.WinUI, new[] { ".cbr", ".cbz" } }, { DevicePlatform.Tizen, new[] { "*/*" } }, { DevicePlatform.macOS, new[] { "cbr", "cbz" } }, // or general UTType values }); diff --git a/src/Essentials/src/DeviceInfo/DeviceInfo.uwp.cs b/src/Essentials/src/DeviceInfo/DeviceInfo.uwp.cs index a018f2f77a2c..a8b359511b2d 100644 --- a/src/Essentials/src/DeviceInfo/DeviceInfo.uwp.cs +++ b/src/Essentials/src/DeviceInfo/DeviceInfo.uwp.cs @@ -54,7 +54,7 @@ public string VersionString public Version Version => Utils.ParseVersion(VersionString); - public DevicePlatform Platform => DevicePlatform.UWP; + public DevicePlatform Platform => DevicePlatform.WinUI; public DeviceIdiom Idiom { diff --git a/src/Essentials/src/FilePicker/FilePicker.uwp.cs b/src/Essentials/src/FilePicker/FilePicker.uwp.cs index 8ff9b0186f9a..cf0db521f516 100644 --- a/src/Essentials/src/FilePicker/FilePicker.uwp.cs +++ b/src/Essentials/src/FilePicker/FilePicker.uwp.cs @@ -71,31 +71,31 @@ public partial class FilePickerFileType static FilePickerFileType PlatformImageFileType() => new FilePickerFileType(new Dictionary> { - { DevicePlatform.UWP, FileSystem.Extensions.AllImage } + { DevicePlatform.WinUI, FileSystem.Extensions.AllImage } }); static FilePickerFileType PlatformPngFileType() => new FilePickerFileType(new Dictionary> { - { DevicePlatform.UWP, new[] { FileSystem.Extensions.Png } } + { DevicePlatform.WinUI, new[] { FileSystem.Extensions.Png } } }); static FilePickerFileType PlatformJpegFileType() => new FilePickerFileType(new Dictionary> { - { DevicePlatform.UWP, FileSystem.Extensions.AllJpeg } + { DevicePlatform.WinUI, FileSystem.Extensions.AllJpeg } }); static FilePickerFileType PlatformVideoFileType() => new FilePickerFileType(new Dictionary> { - { DevicePlatform.UWP, FileSystem.Extensions.AllVideo } + { DevicePlatform.WinUI, FileSystem.Extensions.AllVideo } }); static FilePickerFileType PlatformPdfFileType() => new FilePickerFileType(new Dictionary> { - { DevicePlatform.UWP, new[] { FileSystem.Extensions.Pdf } } + { DevicePlatform.WinUI, new[] { FileSystem.Extensions.Pdf } } }); } } diff --git a/src/Essentials/src/Types/DevicePlatform.shared.cs b/src/Essentials/src/Types/DevicePlatform.shared.cs index f8c56d8cd6ec..9f8f0f101798 100644 --- a/src/Essentials/src/Types/DevicePlatform.shared.cs +++ b/src/Essentials/src/Types/DevicePlatform.shared.cs @@ -25,7 +25,10 @@ namespace Microsoft.Maui.Essentials public static DevicePlatform Tizen { get; } = new DevicePlatform(nameof(Tizen)); /// - public static DevicePlatform UWP { get; } = new DevicePlatform(nameof(UWP)); + [Obsolete("Use WinUI instead.")] + public static DevicePlatform UWP { get; } = new DevicePlatform(nameof(WinUI)); + + public static DevicePlatform WinUI { get; } = new DevicePlatform(nameof(WinUI)); /// public static DevicePlatform watchOS { get; } = new DevicePlatform(nameof(watchOS)); diff --git a/src/Essentials/test/DeviceTests/Tests/DeviceInfo_Tests.cs b/src/Essentials/test/DeviceTests/Tests/DeviceInfo_Tests.cs index 8718e7ed77cb..2d1cb963f064 100644 --- a/src/Essentials/test/DeviceTests/Tests/DeviceInfo_Tests.cs +++ b/src/Essentials/test/DeviceTests/Tests/DeviceInfo_Tests.cs @@ -70,7 +70,7 @@ public void AppPackageName_Is_Correct() public void Platform_Is_Correct() { #if WINDOWS_UWP || WINDOWS - Assert.Equal(DevicePlatform.UWP, DeviceInfo.Platform); + Assert.Equal(DevicePlatform.WinUI, DeviceInfo.Platform); #elif __IOS__ Assert.Equal(DevicePlatform.iOS, DeviceInfo.Platform); #elif __ANDROID__