diff --git a/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets b/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets
index dbde4aba4ed6..04adc2932ca4 100644
--- a/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets
+++ b/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets
@@ -32,10 +32,16 @@
-
-
+
+
+
+
-
+
+
+
+
+
Platform\Windows\
@@ -64,7 +70,6 @@
$(DefineConstants);MACCATALYST;IOS
-
false
@@ -79,6 +84,9 @@
win10-x86;win10-x64;win10-arm64
WINDOWS;$(DefineConstants)
+
+ WINDOWS_UWP;$(DefineConstants)
+
diff --git a/Compatibility.ControlGallery.sln b/Compatibility.ControlGallery.sln
index 046326d40b38..d5f55c5ca59f 100644
--- a/Compatibility.ControlGallery.sln
+++ b/Compatibility.ControlGallery.sln
@@ -77,22 +77,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials.DeviceTests.iOS"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Essentials.DeviceTests.Shared", "src\Essentials\test\DeviceTests.Shared\Essentials.DeviceTests.Shared.csproj", "{81128D28-CFC8-4EA4-B68D-9939339C461A}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{5817A848-0B04-4035-9F7E-B8621B61CBDD}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.UWP", "src\Essentials\samples\Samples.UWP\Samples.UWP.csproj", "{5A1D97F2-6703-4278-BBF2-12C065F7E94A}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Tizen", "src\Essentials\samples\Samples.Tizen\Samples.Tizen.csproj", "{CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.Mac", "src\Essentials\samples\Samples.Mac\Samples.Mac.csproj", "{89899D16-4BD1-49B1-9903-9F6BB26C5DC5}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.iOS", "src\Essentials\samples\Samples.iOS\Samples.iOS.csproj", "{AB6242B7-634F-4839-A991-7629D0D2C636}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.Android", "src\Essentials\samples\Samples.Android\Samples.Android.csproj", "{3C0CDEF3-495E-45F4-8B12-0E05EF11295C}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples", "src\Essentials\samples\Samples\Samples.csproj", "{2C69EB76-02C4-4921-96A1-4D70CB7CE744}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Server.WebAuthenticator", "src\Essentials\samples\Sample.Server.WebAuthenticator\Sample.Server.WebAuthenticator.csproj", "{0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Benchmarks", "src\Core\tests\Benchmarks\Core.Benchmarks.csproj", "{73100F0D-C0BB-4F16-8FC2-FA3FA8ACD424}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{806499EB-C2CC-4E85-BC19-613F3DE5E0C3}"
@@ -654,218 +638,6 @@ Global
{81128D28-CFC8-4EA4-B68D-9939339C461A}.Release|x64.Build.0 = Release|Any CPU
{81128D28-CFC8-4EA4-B68D-9939339C461A}.Release|x86.ActiveCfg = Release|Any CPU
{81128D28-CFC8-4EA4-B68D-9939339C461A}.Release|x86.Build.0 = Release|Any CPU
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|Any CPU.ActiveCfg = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|Any CPU.Build.0 = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|Any CPU.Deploy.0 = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|ARM.ActiveCfg = Debug|ARM
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|ARM.Build.0 = Debug|ARM
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|ARM.Deploy.0 = Debug|ARM
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|ARM64.ActiveCfg = Debug|ARM64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|ARM64.Build.0 = Debug|ARM64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|ARM64.Deploy.0 = Debug|ARM64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|iPhone.ActiveCfg = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|iPhone.Build.0 = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|iPhone.Deploy.0 = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|iPhoneSimulator.ActiveCfg = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|iPhoneSimulator.Build.0 = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|iPhoneSimulator.Deploy.0 = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|x64.ActiveCfg = Debug|x64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|x64.Build.0 = Debug|x64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|x64.Deploy.0 = Debug|x64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|x86.ActiveCfg = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|x86.Build.0 = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Debug|x86.Deploy.0 = Debug|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|Any CPU.ActiveCfg = Release|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|ARM.ActiveCfg = Release|ARM
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|ARM.Build.0 = Release|ARM
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|ARM.Deploy.0 = Release|ARM
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|ARM64.ActiveCfg = Release|ARM64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|ARM64.Build.0 = Release|ARM64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|ARM64.Deploy.0 = Release|ARM64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|iPhone.ActiveCfg = Release|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|iPhoneSimulator.ActiveCfg = Release|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|x64.ActiveCfg = Release|x64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|x64.Build.0 = Release|x64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|x64.Deploy.0 = Release|x64
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|x86.ActiveCfg = Release|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|x86.Build.0 = Release|x86
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A}.Release|x86.Deploy.0 = Release|x86
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|ARM.Build.0 = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|ARM64.Build.0 = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|iPhone.Build.0 = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|x64.ActiveCfg = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|x64.Build.0 = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|x86.ActiveCfg = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Debug|x86.Build.0 = Debug|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|Any CPU.Build.0 = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|ARM.ActiveCfg = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|ARM.Build.0 = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|ARM64.ActiveCfg = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|ARM64.Build.0 = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|iPhone.ActiveCfg = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|iPhone.Build.0 = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|x64.ActiveCfg = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|x64.Build.0 = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|x86.ActiveCfg = Release|Any CPU
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348}.Release|x86.Build.0 = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|ARM.Build.0 = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|ARM64.Build.0 = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|iPhone.Build.0 = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|x64.ActiveCfg = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|x64.Build.0 = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|x86.ActiveCfg = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Debug|x86.Build.0 = Debug|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|Any CPU.Build.0 = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|ARM.ActiveCfg = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|ARM.Build.0 = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|ARM64.ActiveCfg = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|ARM64.Build.0 = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|iPhone.ActiveCfg = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|iPhone.Build.0 = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|x64.ActiveCfg = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|x64.Build.0 = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|x86.ActiveCfg = Release|Any CPU
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5}.Release|x86.Build.0 = Release|Any CPU
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|ARM.ActiveCfg = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|ARM64.ActiveCfg = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|iPhone.ActiveCfg = Debug|iPhone
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|iPhone.Build.0 = Debug|iPhone
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|iPhone.Deploy.0 = Debug|iPhone
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|x64.ActiveCfg = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|x64.Build.0 = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|x64.Deploy.0 = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Debug|x86.ActiveCfg = Debug|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|ARM.ActiveCfg = Release|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|ARM64.ActiveCfg = Release|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|iPhone.ActiveCfg = Release|iPhone
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|iPhone.Build.0 = Release|iPhone
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|x64.ActiveCfg = Release|iPhoneSimulator
- {AB6242B7-634F-4839-A991-7629D0D2C636}.Release|x86.ActiveCfg = Release|iPhoneSimulator
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|ARM.Build.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|ARM.Deploy.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|ARM64.Build.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|ARM64.Deploy.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|iPhone.Build.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|iPhone.Deploy.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|x64.ActiveCfg = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|x64.Build.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|x64.Deploy.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|x86.ActiveCfg = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|x86.Build.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Debug|x86.Deploy.0 = Debug|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|Any CPU.Build.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|ARM.ActiveCfg = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|ARM.Build.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|ARM.Deploy.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|ARM64.ActiveCfg = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|ARM64.Build.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|ARM64.Deploy.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|iPhone.ActiveCfg = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|iPhone.Build.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|iPhone.Deploy.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|x64.ActiveCfg = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|x64.Build.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|x64.Deploy.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|x86.ActiveCfg = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|x86.Build.0 = Release|Any CPU
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C}.Release|x86.Deploy.0 = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|ARM.Build.0 = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|ARM64.Build.0 = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|iPhone.Build.0 = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|x64.ActiveCfg = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|x64.Build.0 = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|x86.ActiveCfg = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Debug|x86.Build.0 = Debug|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|Any CPU.Build.0 = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|ARM.ActiveCfg = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|ARM.Build.0 = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|ARM64.ActiveCfg = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|ARM64.Build.0 = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|iPhone.ActiveCfg = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|iPhone.Build.0 = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|x64.ActiveCfg = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|x64.Build.0 = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|x86.ActiveCfg = Release|Any CPU
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744}.Release|x86.Build.0 = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|ARM.Build.0 = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|ARM64.Build.0 = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|iPhone.Build.0 = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|x64.ActiveCfg = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|x64.Build.0 = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|x86.ActiveCfg = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Debug|x86.Build.0 = Debug|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|Any CPU.Build.0 = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|ARM.ActiveCfg = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|ARM.Build.0 = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|ARM64.ActiveCfg = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|ARM64.Build.0 = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|iPhone.ActiveCfg = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|iPhone.Build.0 = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|x64.ActiveCfg = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|x64.Build.0 = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|x86.ActiveCfg = Release|Any CPU
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C}.Release|x86.Build.0 = Release|Any CPU
{73100F0D-C0BB-4F16-8FC2-FA3FA8ACD424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73100F0D-C0BB-4F16-8FC2-FA3FA8ACD424}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73100F0D-C0BB-4F16-8FC2-FA3FA8ACD424}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -1566,14 +1338,6 @@ Global
{2E0EB4A3-3C4A-4A5E-8D2F-F77C62464886} = {99FDF6CA-DCF8-4CB2-B2EA-E24CCB601232}
{B73EB308-70BE-49FD-91A7-1D1495663D6D} = {99FDF6CA-DCF8-4CB2-B2EA-E24CCB601232}
{81128D28-CFC8-4EA4-B68D-9939339C461A} = {99FDF6CA-DCF8-4CB2-B2EA-E24CCB601232}
- {5817A848-0B04-4035-9F7E-B8621B61CBDD} = {DFD73007-5DB1-43AD-87A8-BD8622C2B192}
- {5A1D97F2-6703-4278-BBF2-12C065F7E94A} = {5817A848-0B04-4035-9F7E-B8621B61CBDD}
- {CFBEEB38-D3E8-4100-8CFB-E0A9C4FC0348} = {5817A848-0B04-4035-9F7E-B8621B61CBDD}
- {89899D16-4BD1-49B1-9903-9F6BB26C5DC5} = {5817A848-0B04-4035-9F7E-B8621B61CBDD}
- {AB6242B7-634F-4839-A991-7629D0D2C636} = {5817A848-0B04-4035-9F7E-B8621B61CBDD}
- {3C0CDEF3-495E-45F4-8B12-0E05EF11295C} = {5817A848-0B04-4035-9F7E-B8621B61CBDD}
- {2C69EB76-02C4-4921-96A1-4D70CB7CE744} = {5817A848-0B04-4035-9F7E-B8621B61CBDD}
- {0C1B038F-F5CD-4E3C-B9D7-040F020BA44C} = {5817A848-0B04-4035-9F7E-B8621B61CBDD}
{73100F0D-C0BB-4F16-8FC2-FA3FA8ACD424} = {2ACC7FFA-238F-44FD-93CB-4D9B17D8C4BA}
{806499EB-C2CC-4E85-BC19-613F3DE5E0C3} = {9AD757F5-E57A-459D-A0A7-E0675E045B84}
{90B727DD-4C7B-4462-950F-61842A87DE8A} = {806499EB-C2CC-4E85-BC19-613F3DE5E0C3}
diff --git a/src/Compatibility/ControlGallery/src/Android/FormsAppCompatActivity.cs b/src/Compatibility/ControlGallery/src/Android/FormsAppCompatActivity.cs
index 93c21a8a0533..8f183d9f9a68 100644
--- a/src/Compatibility/ControlGallery/src/Android/FormsAppCompatActivity.cs
+++ b/src/Compatibility/ControlGallery/src/Android/FormsAppCompatActivity.cs
@@ -10,6 +10,7 @@
using Microsoft.Maui.Controls.Internals;
using System.Threading.Tasks;
using System.Net.Http;
+using Microsoft.Maui.Handlers;
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.Android
{
@@ -56,7 +57,7 @@ protected override void OnCreate(Bundle bundle)
FormsMaps.Init(this, bundle);
#if ENABLE_TEST_CLOUD
- Handlers.ViewHandler
+ ViewHandler
.ViewMapper[nameof(IView.AutomationId)] = (h, v) =>
{
((global::Android.Views.View)h.NativeView).ContentDescription = v.AutomationId;
diff --git a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core-net6.csproj b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core-net6.csproj
index b32645ecd9bc..b0181fb7ffa8 100644
--- a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core-net6.csproj
+++ b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core-net6.csproj
@@ -20,7 +20,7 @@
0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429
- $(DefineConstants);__UWP__
+ $(DefineConstants);WINDOWS
diff --git a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj
index 47c155fd1d0f..ac6a7f0086c6 100644
--- a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj
+++ b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj
@@ -20,7 +20,7 @@
0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429
- $(DefineConstants);__UWP__
+ $(DefineConstants);WINDOWS
diff --git a/src/Compatibility/ControlGallery/src/Core/GalleryPages/CellTypeList.cs b/src/Compatibility/ControlGallery/src/Core/GalleryPages/CellTypeList.cs
index 6a517327b5be..7c0ea5f775cd 100644
--- a/src/Compatibility/ControlGallery/src/Core/GalleryPages/CellTypeList.cs
+++ b/src/Compatibility/ControlGallery/src/Core/GalleryPages/CellTypeList.cs
@@ -71,7 +71,7 @@ public CellTypeList()
Navigation.PushAsync(cellNav.Page);
_last = cellNav;
-#if !__WINDOWS__
+#if !WINDOWS
SelectedItem = null;
#endif
};
diff --git a/src/Compatibility/ControlGallery/src/EmbeddingTestBeds/Embedding.UWP/Embedding.UWP.csproj b/src/Compatibility/ControlGallery/src/EmbeddingTestBeds/Embedding.UWP/Embedding.UWP.csproj
index 8fd741937aea..76e3504171ac 100644
--- a/src/Compatibility/ControlGallery/src/EmbeddingTestBeds/Embedding.UWP/Embedding.UWP.csproj
+++ b/src/Compatibility/ControlGallery/src/EmbeddingTestBeds/Embedding.UWP/Embedding.UWP.csproj
@@ -24,7 +24,7 @@
true
bin\x86\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
x86
@@ -34,7 +34,7 @@
bin\x86\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
@@ -47,7 +47,7 @@
true
bin\ARM\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
ARM
@@ -57,7 +57,7 @@
bin\ARM\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
@@ -70,7 +70,7 @@
true
bin\x64\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
x64
@@ -80,7 +80,7 @@
bin\x64\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla30353.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla30353.cs
index 6e98e72eb23a..dfe0b388cc1f 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla30353.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla30353.cs
@@ -125,7 +125,7 @@ public override void TearDown()
void Back()
{
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
RunningApp.Tap(q => q.Marked("Toggle"));
#else
RunningApp.Back();
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla40408.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla40408.cs
index d01b091de0ff..eebfe248232c 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla40408.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla40408.cs
@@ -124,7 +124,7 @@ void FlyoutPage1_Appearing(object sender, EventArgs e)
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void OnAppearingEvents()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla41271.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla41271.cs
index 1c441877f0bb..a864181c60cc 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla41271.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla41271.cs
@@ -123,7 +123,7 @@ protected override void Init()
}
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
string Cell;
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla43519.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla43519.cs
index c43edf4afe6b..b61abd2650d6 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla43519.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla43519.cs
@@ -79,7 +79,7 @@ protected override void Init()
});
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void TabbedModalNavigation()
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla43663.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla43663.cs
index bc85fb201c66..6dfce101dd09 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla43663.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla43663.cs
@@ -125,7 +125,7 @@ void ModalPopped(object sender, ModalPoppedEventArgs e)
DisplayAlert("Popped", Message, Cancel);
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void ModalNavigation()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla45722.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla45722.cs
index a294f0951d59..17fab3f08822 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla45722.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla45722.cs
@@ -156,7 +156,7 @@ protected override void OnDisappearing()
base.OnDisappearing();
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void LabelsInListViewTemplatesShouldBeCollected()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla45722Xaml0.xaml.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla45722Xaml0.xaml.cs
index a300e814290a..f0a22256a199 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla45722Xaml0.xaml.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla45722Xaml0.xaml.cs
@@ -93,7 +93,7 @@ void RefreshModel()
}
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void LabelsInListViewTemplatesShouldBeCollected()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla51825.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla51825.cs
index 464b07ed82f4..be24c93b41c5 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla51825.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla51825.cs
@@ -61,7 +61,7 @@ public void Bugzilla51825Test()
// Windows App Driver and the Search Bar are a bit buggy
// It randomly doesn't enter the first letter
-#if !__WINDOWS__
+#if !WINDOWS
Assert.AreEqual("Hello", label.ReadText());
#endif
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla60122.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla60122.cs
index 2ab8d2a18226..dee0fff61bdb 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla60122.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla60122.cs
@@ -52,7 +52,7 @@ public void HandleLongPress(object sender, EventArgs e)
}
}
-#if UITEST && !__WINDOWS__
+#if UITEST && !WINDOWS
// This test won't work on Windows right now because we can only test desktop, so touch events
// (like LongPress) don't really work. The test should work manually on a touch screen, though.
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/DateTimePickerLocalizationTests.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/DateTimePickerLocalizationTests.cs
index d73df7bd95a2..7b14d56cca93 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/DateTimePickerLocalizationTests.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/DateTimePickerLocalizationTests.cs
@@ -59,7 +59,7 @@ public string DateString(String format, String date)
public void TimePicker24H()
{
RunningApp.Tap(x => x.Marked("TimePicker"));
-#if !__WINDOWS__
+#if !WINDOWS
Assert.AreEqual("0.0.0 A", TimeString("H.m.s t", "0, 0"));
Assert.AreEqual("13:05 PM", TimeString("HH:mm tt", "13, 5"));
Assert.AreEqual("12 PM", TimeString("HH tt", "12, 0"));
@@ -70,7 +70,7 @@ public void TimePicker24H()
#endif
}
-#if !__WINDOWS__
+#if !WINDOWS
[Test]
public void TimePicker12H()
{
@@ -99,7 +99,7 @@ public void TimePickerOther()
public void DatePickerDMY()
{
RunningApp.Tap(x => x.Marked("DatePicker"));
-#if !__WINDOWS__
+#if !WINDOWS
Assert.AreEqual("31/1/99", DateString("d/M/y", "1999, 1, 31"));
Assert.AreEqual("02-29-00", DateString("MM-dd-yy", "2000, 2, 29"));
Assert.AreEqual("2010, Apr, Thu", DateString("yyy, MMM, ddd", "2010, 4, 15"));
@@ -118,7 +118,7 @@ public void DatePickerDMY()
public void DatePickerMissing()
{
RunningApp.Tap(x => x.Marked("DatePicker"));
-#if !__WINDOWS__
+#if !WINDOWS
Assert.AreEqual("October 97", DateString("MMMM yy", "1997, 10, 30"));
Assert.AreEqual("Monday", DateString("dddd", "2020, 7, 20"));
Assert.AreEqual("2002: Dec", DateString("yyyy: MMM", "2002, 12, 31"));
@@ -129,7 +129,7 @@ public void DatePickerMissing()
#endif
}
-#if !__WINDOWS__
+#if !WINDOWS
[Test]
public void DatePickerLetters()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/GestureBubblingTests.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/GestureBubblingTests.cs
index f3e276bc20a7..190b4d32c95f 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/GestureBubblingTests.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/GestureBubblingTests.cs
@@ -163,7 +163,7 @@ from Layout element in layout.InternalChildren
from Button button in element.InternalChildren
let text = button.Text
// UwpIgnore
-#if __WINDOWS__
+#if WINDOWS
where text != "Stepper" && text != "Entry"
#endif
select new object[]
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Helpers/UITestHelper.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Helpers/UITestHelper.cs
index e57bc5bc32b7..2cef291b5e10 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Helpers/UITestHelper.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Helpers/UITestHelper.cs
@@ -16,7 +16,7 @@ public static class UITestHelper
{
public static bool IsWindowClosedException(this Exception exc)
{
-#if __WINDOWS__
+#if WINDOWS
return exc.Message?.Contains("Currently selected window has been closed") ?? false;
#else
return false;
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1704.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1704.cs
index 1cbbd5cf9233..fa62f79de7b4 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1704.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1704.cs
@@ -490,7 +490,7 @@ public MiscPage()
int.TryParse(_stressTestItertionEntry.Text, out _stressTestIterationCount);
-#if __UWP__
+#if WINDOWS
Task.Run(runStressTest);
#else
ThreadPool.QueueUserWorkItem(delegate
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1777.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1777.cs
index d6c573757346..40bb71fb8300 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1777.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1777.cs
@@ -83,7 +83,7 @@ void button_Clicked(object sender, EventArgs e)
_pickerNormal.Items.Add("test " + _pickerNormal.Items.Count);
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void Issue1777Test()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1937.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1937.cs
index b9df16e7980a..54b8ff6c9e74 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1937.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue1937.cs
@@ -92,7 +92,7 @@ protected override void Init()
};
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void Issue1937Test ()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2339.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2339.cs
index c9c6d7a5063c..9dad86b9d602 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2339.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2339.cs
@@ -84,7 +84,7 @@ protected override void Init()
#if UITEST
[Test]
-#if __WINDOWS__
+#if WINDOWS
[Ignore("Focus Behavior is different on UWP")]
#endif
public void FocusAndUnFocusMultipleTimes()
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2399.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2399.cs
index 3c3e78c8ecce..42bb5b24824a 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2399.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2399.cs
@@ -15,7 +15,7 @@ namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 2399, "Label Renderer Dispose never called")]
-#if __WINDOWS__
+#if WINDOWS
// this test works fine when ran manually but when executed through the test runner
// it fails. Not sure the difference
[NUnit.Framework.Category(Compatibility.UITests.UITestCategories.ManualReview)]
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2809.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2809.cs
index 5def3e50233f..13ac49a6a570 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2809.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2809.cs
@@ -47,7 +47,7 @@ void ShouldShowMenu()
#if __ANDROID__
//show secondary menu
RunningApp.TapOverflowMenuButton();
-#elif __WINDOWS__
+#elif WINDOWS
RunningApp.Tap ("MoreButton");
#endif
}
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2894.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2894.cs
index f53b62502987..cd68ded450bf 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2894.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2894.cs
@@ -250,7 +250,7 @@ public void VariousSpanGesturePermutation()
do
{
-#if __WINDOWS__
+#if WINDOWS
RunningApp.TapCoordinates(target.X + target.Width - 10, target.Y + 2);
#else
RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2);
@@ -267,7 +267,7 @@ public void VariousSpanGesturePermutation()
RunningApp.Tap($"TestSpan5");
RunningApp.TapCoordinates(target.X + 5, target.Y + 5);
-#if __WINDOWS__
+#if WINDOWS
RunningApp.TapCoordinates(target.X + target.Width - 10, target.Y + 2);
#else
RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2);
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2981.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2981.cs
index 449e02833d1c..176c77ae2c57 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2981.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue2981.cs
@@ -26,7 +26,7 @@ protected override void Init()
Content = listView;
}
-#if UITEST && !__WINDOWS__
+#if UITEST && !WINDOWS
// This test won't work on Windows right now because we can only test desktop, so touch events
// (like LongPress) don't really work. The test should work manually on a touch screen, though.
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3139.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3139.cs
index cadc03f42550..75bebeb4fa7f 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3139.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3139.cs
@@ -44,7 +44,7 @@ protected override async void Init()
await alertTask;
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void Issue3139Test ()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3652.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3652.cs
index 14539c04d8dc..7b9a64772567 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3652.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3652.cs
@@ -114,7 +114,7 @@ public class ListItemViewModel
new Command(() => MessagingCenter.Send(this, "Remove", this));
}
-#if UITEST && !__WINDOWS__
+#if UITEST && !WINDOWS
[Test]
public void TestRemovingContextMenuItems()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3840.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3840.cs
index 3addb02634ce..d63b281e9f43 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3840.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue3840.cs
@@ -87,7 +87,7 @@ public void TranslatingViewKeepsScrollViewPosition()
RunningApp.WaitForElement(_failedText);
RunningApp.Tap(_button1);
RunningApp.Tap(_button2);
-#if __WINDOWS__
+#if WINDOWS
var label = RunningApp.WaitForElement(_failedText);
Assert.AreEqual(0, label[0].Rect.Height);
Assert.AreEqual(0, label[0].Rect.Width);
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue4597.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue4597.cs
index 587e820ea062..d1dd63b462e4 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue4597.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue4597.cs
@@ -173,7 +173,7 @@ protected override void Init()
}
#if UITEST
-#if !__WINDOWS__
+#if !WINDOWS
[Test]
public void ImageFromFileSourceAppearsAndDisappearsCorrectly()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5412.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5412.cs
index cc474f2c425b..b586da07927c 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5412.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5412.cs
@@ -25,7 +25,7 @@ protected override async void Init()
await Navigation.PushModalAsync(new Issue5412MainPage());
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void Issue5412Test()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5886.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5886.cs
index 153d17f7e692..c43427fd82ec 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5886.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5886.cs
@@ -79,7 +79,7 @@ void Button_Clicked1(object sender, EventArgs e)
button1.IsVisible = true;
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void ReplaceRenderer()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue6323.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue6323.cs
index f5ae1415403b..eec97bd03e4e 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue6323.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue6323.cs
@@ -27,7 +27,7 @@ protected override void Init()
});
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
[Test]
public void Issue6323Test()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue7167.xaml.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue7167.xaml.cs
index 907936545e14..5216920205d0 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue7167.xaml.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue7167.xaml.cs
@@ -6,7 +6,7 @@
using Microsoft.Maui.Controls.CustomAttributes;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Xaml;
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
using Xamarin.UITest;
using Microsoft.Maui.Controls.Compatibility.UITests;
using NUnit.Framework;
@@ -40,7 +40,7 @@ void MyListView_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
}
-#if UITEST && __WINDOWS__
+#if UITEST && WINDOWS
const string ListViewId = "ListViewId";
const string AddCommandID = "AddCommandID";
const string ClearListCommandId = "ClearListCommandId";
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue7181.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue7181.cs
index 1f75166b50da..d1b2dfc83a42 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue7181.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue7181.cs
@@ -60,7 +60,7 @@ protected override void Init()
private void OnToolbarClicked() =>
_toolbarItem.Text = $"{AfterClickToolbarItemText} {_clicks++}";
-#if UITEST && (__ANDROID__ || __WINDOWS__)
+#if UITEST && (__ANDROID__ || WINDOWS)
[Test]
public void ShellToolbarItemTests()
{
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue8821.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue8821.cs
index a4bbbbe6ef63..14fe4e0d5b6c 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue8821.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue8821.cs
@@ -74,13 +74,7 @@ async Task CreateImage(string imageUrl)
{
var bytes = await DownloadImageAsync(imageUrl);
- string path;
-
-#if WINDOWS_UWP
- path = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
-#else
- path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
-#endif
+ string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
SecondImageSource = IOPath.Combine(path, "Issue8821.gif");
File.WriteAllBytes(SecondImageSource, bytes);
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/TestPages/ScreenshotConditionalApp.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/TestPages/ScreenshotConditionalApp.cs
index b6ce01d895d3..357f5f68a7d9 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/TestPages/ScreenshotConditionalApp.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/TestPages/ScreenshotConditionalApp.cs
@@ -221,7 +221,7 @@ public void WaitFor(Func predicate, string timeoutMessage = "Timed out wai
public AppResult WaitForFirstElement(string marked, string timeoutMessage = "Timed out waiting for element...",
TimeSpan? timeout = null, TimeSpan? retryFrequency = null)
{
-#if __WINDOWS__
+#if WINDOWS
return (_app as WinDriverApp).WaitForFirstElement(marked, timeoutMessage, timeout, retryFrequency);
#else
return _app.WaitForElement(marked, timeoutMessage, timeout, retryFrequency).FirstOrDefault();
@@ -463,7 +463,7 @@ public ITestServer TestServer
get { return _app.TestServer; }
}
-#if __WINDOWS__
+#if WINDOWS
public string ReadDatePicker(string marked)
{
return ((WinDriverApp)_app).ReadDatePicker(marked).ToString();
@@ -490,7 +490,7 @@ public void TestSetup(Type testType, bool isolate)
UITestHelper.MarkTestInconclusiveIfNoInternetConnectionIsPresent(testType, _app);
-#if __WINDOWS__
+#if WINDOWS
RestartIfAppIsClosed();
#endif
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/TestPages/TestPages.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/TestPages/TestPages.cs
index bacc0592a11d..77fa1324e935 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/TestPages/TestPages.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/TestPages/TestPages.cs
@@ -55,7 +55,7 @@ static IApp InitializeApp()
Xamarin.UITest.Desktop.TestAgent.Start();
app = InitializeMacOSApp();
-#elif __WINDOWS__
+#elif WINDOWS
app = InitializeUWPApp();
#endif
if (app == null)
@@ -144,7 +144,7 @@ static IApp InitializeMacOSApp()
}
#endif
-#if __WINDOWS__
+#if WINDOWS
static IApp InitializeUWPApp()
{
return WindowsTestBase.ConfigureApp();
@@ -170,7 +170,7 @@ public static void NavigateToIssue(Type type, IApp app)
int maxAttempts = 2;
int attempts = 0;
-#if __WINDOWS__
+#if WINDOWS
bool attemptOneRestart = false;
bool waitNoElementAttempt = false;
#endif
@@ -195,7 +195,7 @@ public static void NavigateToIssue(Type type, IApp app)
}
#endif
-#if __WINDOWS__
+#if WINDOWS
// Windows doens't have an 'invoke' option right now for us to do the more direct navigation
// we're using for Android/iOS
// So we're just going to use the 'Reset' method to bounce the app to the opening screen
@@ -223,7 +223,7 @@ public static void NavigateToIssue(Type type, IApp app)
app.WaitForElement(q => q.Raw("* marked:'SearchButton'"));
app.Tap(q => q.Raw("* marked:'SearchButton'"));
-#if __WINDOWS__
+#if WINDOWS
try
{
if (!waitNoElementAttempt)
@@ -243,7 +243,7 @@ public static void NavigateToIssue(Type type, IApp app)
if (!app.RestartIfAppIsClosed())
return;
}
-#if __WINDOWS__
+#if WINDOWS
catch (Exception we)
when (we.IsWindowClosedException() && !attemptOneRestart)
{
@@ -573,7 +573,7 @@ public virtual void TearDown()
public abstract class TestShell : Shell
{
protected const string FlyoutIconAutomationId = "OK";
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
protected const string BackButtonAutomationId = "Back";
#else
protected const string BackButtonAutomationId = "OK";
@@ -828,7 +828,7 @@ public void TapBackArrow(string backArrowIcon = BackButtonAutomationId)
public void TapInFlyout(string text, string flyoutIcon = FlyoutIconAutomationId, bool usingSwipe = false, string timeoutMessage = null, bool makeSureFlyoutStaysOpen = false)
{
timeoutMessage = timeoutMessage ?? text;
-#if __WINDOWS__
+#if WINDOWS
RunningApp.WaitForElement(flyoutIcon);
#endif
diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/VisualControlsPage.xaml.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/VisualControlsPage.xaml.cs
index e72b73e0539c..3627f7f2d728 100644
--- a/src/Compatibility/ControlGallery/src/Issues.Shared/VisualControlsPage.xaml.cs
+++ b/src/Compatibility/ControlGallery/src/Issues.Shared/VisualControlsPage.xaml.cs
@@ -38,7 +38,7 @@ protected override void Init()
{
}
-#if UITEST && !__WINDOWS__
+#if UITEST && !WINDOWS
[Test]
public void LoadingVisualGalleryPageDoesNotCrash()
{
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/BaseTestFixture.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/BaseTestFixture.cs
index f14bb96c7db2..f6c7274b187e 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/BaseTestFixture.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/BaseTestFixture.cs
@@ -108,7 +108,7 @@ protected void ResetApp()
#if __ANDROID__
App.Invoke("Reset");
#endif
-#if __WINDOWS__
+#if WINDOWS
WindowsTestBase.Reset();
#endif
}
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/PlatformQueries.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/PlatformQueries.cs
index c7fcfb18616f..b1bb682c437d 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/PlatformQueries.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/PlatformQueries.cs
@@ -29,7 +29,7 @@ internal static class PlatformMethodQueries
{ View.ScaleProperty, Tuple.Create (new[] { "getLayerTransformString" }, true) },
};
-#elif __ANDROID__ || __WINDOWS__
+#elif __ANDROID__ || WINDOWS
public static readonly Dictionary> PropertyPlatformMethodDictionary = new Dictionary
>
{
@@ -86,7 +86,7 @@ internal static class PlatformViews
public static readonly string TableView = "UITableView";
public static readonly string TimePicker = "UITextField";
public static readonly string WebView = "WKWebView";
-#elif __ANDROID__ || __WINDOWS__
+#elif __ANDROID__ || WINDOWS
public static readonly string ActivityIndicator = "android.widget.ProgressBar";
public static readonly string BoxView = "xamarin.forms.platform.android.BoxRenderer";
public static readonly string Button = "android.widget.Button";
@@ -124,7 +124,7 @@ internal static class PlatformQueries
public static readonly Func PageWithoutNavigationBar = q => q.Raw("*").Index(7);
public static readonly Func NavigationBarBackButton = q => q.Class("UINavigationItemButtonView");
-#elif __ANDROID__ || __WINDOWS__
+#elif __ANDROID__ || WINDOWS
public static readonly Func Root = q => q.Id("content");
public static readonly Func RootPageListView = q => q.Raw("ListViewRenderer index:0");
public static readonly Func GalleryListView = q => q.Raw("ListViewRenderer index:1");
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Queries.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Queries.cs
index 019c34a37d77..5d488eb216ac 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Queries.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Queries.cs
@@ -112,7 +112,7 @@ internal static class Rects
{
public static AppRect RootViewRect(this IApp app)
{
-#if __WINDOWS__
+#if WINDOWS
return app.Query(WinDriverApp.AppName)[0].Rect;
#else
return app.Query(q => q.Raw("* index:0"))[0].Rect;
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ActionSheetUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ActionSheetUITests.cs
index 9d78d28062bd..c5cb97532539 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ActionSheetUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ActionSheetUITests.cs
@@ -163,7 +163,7 @@ void ScrollAndTap(string actionSheet)
{
var queryString = $"* text:'{actionSheet}'";
Func actionSheetQuery = q => q.Raw(queryString);
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(actionSheetQuery);
#elif __MACOS__
App.Tap(actionSheetQuery);
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ActivityIndicatorUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ActivityIndicatorUITests.cs
index 88861cb41f8e..b894baf49fbc 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ActivityIndicatorUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ActivityIndicatorUITests.cs
@@ -55,7 +55,7 @@ public void IsRunning()
remote.GoTo();
#if __MACOS__
Assert.Inconclusive("Not tested yet");
-#elif __WINDOWS__
+#elif WINDOWS
Assert.Inconclusive(PleaseInspect);
#else
var isRunning = remote.GetProperty(ActivityIndicator.IsRunningProperty);
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/BoxViewUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/BoxViewUITests.cs
index dc69cd782ef3..e1538febcc81 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/BoxViewUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/BoxViewUITests.cs
@@ -54,12 +54,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -78,7 +78,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ButtonUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ButtonUITests.cs
index 83ac4ad2bf25..acfe0e97aa86 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ButtonUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ButtonUITests.cs
@@ -179,12 +179,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -203,7 +203,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/CheckBoxUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/CheckBoxUITests.cs
index 4e2a7a753801..0cb41e3dc55a 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/CheckBoxUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/CheckBoxUITests.cs
@@ -50,12 +50,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -74,7 +74,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/DatePickerUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/DatePickerUITests.cs
index f6681fee35c8..a0e71bb479ed 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/DatePickerUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/DatePickerUITests.cs
@@ -52,12 +52,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -76,7 +76,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/EditorUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/EditorUITests.cs
index b081f036b254..716670de53df 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/EditorUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/EditorUITests.cs
@@ -52,12 +52,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -76,7 +76,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/EntryUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/EntryUITests.cs
index 2ae896be04ef..436d80b34d8c 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/EntryUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/EntryUITests.cs
@@ -103,12 +103,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -127,7 +127,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/FrameUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/FrameUITests.cs
index b69d5a22fc89..37507a847a7f 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/FrameUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/FrameUITests.cs
@@ -54,12 +54,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -78,7 +78,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ImageButtonUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ImageButtonUITests.cs
index d00695ab57a2..3df1e10b90fc 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ImageButtonUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ImageButtonUITests.cs
@@ -161,12 +161,12 @@ public void Image()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -185,7 +185,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ImageUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ImageUITests.cs
index 7492cc948d6f..825abca6981b 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ImageUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ImageUITests.cs
@@ -58,12 +58,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -82,7 +82,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/LabelUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/LabelUITests.cs
index 5fcaecca38f4..f9a748694c37 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/LabelUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/LabelUITests.cs
@@ -51,12 +51,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -75,7 +75,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/Legacy-CellsUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/Legacy-CellsUITests.cs
index d6ca8beac60f..58a9f48bdad5 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/Legacy-CellsUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/Legacy-CellsUITests.cs
@@ -27,7 +27,7 @@ protected override void NavigateToGallery()
void SelectTest(string testName)
{
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(testName);
#else
App.ScrollForElement($"* marked:'{testName}'",
@@ -58,7 +58,7 @@ public void CellsGalleryTextCellList()
string target = "Detail 99";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(1));
#else
App.ScrollForElement($"* marked:'{target}'",
@@ -84,7 +84,7 @@ public void CellsGalleryTextCellTable()
string target = "Detail 12";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(1));
#else
App.ScrollForElement($"* marked:'{target}'",
@@ -114,7 +114,7 @@ public void CellsGalleryImageCellList()
string target = "Detail 99";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(3));
#else
var scrollBounds = App.Query(q => q.Marked(CellTestContainerId)).First().Rect;
@@ -126,7 +126,7 @@ public void CellsGalleryImageCellList()
App.Screenshot("All ImageCells are present");
-#if !__WINDOWS__
+#if !WINDOWS
var numberOfImages = App.Query(q => q.Raw(PlatformViews.Image)).Length;
// Check that there are images present. In Android,
// have to make sure that there are more than 2 for navigation.
@@ -188,7 +188,7 @@ public void CellsGalleryImageCellTable()
string target = "Detail 12";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(1));
#else
App.ScrollForElement($"* marked:'{target}'",
@@ -199,7 +199,7 @@ public void CellsGalleryImageCellTable()
App.Screenshot("All ImageCells are present");
-#if !__WINDOWS__
+#if !WINDOWS
var numberOfImages = App.Query(q => q.Raw(PlatformViews.Image)).Length;
// Check that there are images present. In Android,
// have to make sure that there are more than 2 for navigation.
@@ -223,7 +223,7 @@ public void CellsGallerySwitchCellList()
string target = "Label 99";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(1));
#else
App.ScrollForElement($"* marked:'{target}'",
@@ -252,7 +252,7 @@ public void CellsGallerySwitchCellTable()
string target = "text 32";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(1));
#else
App.ScrollForElement($"* marked:'{target}'",
@@ -281,7 +281,7 @@ public void CellsGalleryEntryCellList()
string target = "Label 99";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(3));
#else
App.ScrollForElement($"* marked:'{target}'",
@@ -305,7 +305,7 @@ public void CellsGalleryEntryCellTable()
string target = "Text 32";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(1));
#else
App.ScrollForElement($"* marked:'{target}'",
@@ -329,7 +329,7 @@ public void CellsGalleryEntryCellCompleted()
string target = "Enter text";
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(target, CellTestContainerId, timeout: TimeSpan.FromMinutes(1));
#else
App.ScrollForElement($"* marked:'{target}'",
@@ -340,7 +340,7 @@ public void CellsGalleryEntryCellCompleted()
App.Screenshot("Before clicking Entry");
-#if !__IOS__ && !__WINDOWS__
+#if !__IOS__ && !WINDOWS
App.Tap(PlatformQueries.EntryCellWithPlaceholder("I am a placeholder"));
App.EnterText(PlatformQueries.EntryCellWithPlaceholder("I am a placeholder"), "Hi");
App.Screenshot("Entered Text");
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/PickerUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/PickerUITests.cs
index b1810c0a3c10..12f5c179b22b 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/PickerUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/PickerUITests.cs
@@ -44,12 +44,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -68,7 +68,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ProgressBarUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ProgressBarUITests.cs
index 7262c70bf659..4204c33f6aaa 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ProgressBarUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ProgressBarUITests.cs
@@ -51,12 +51,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -75,7 +75,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/RadioButtonUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/RadioButtonUITests.cs
index 9fe5cfb88aa7..4c38c3b119e5 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/RadioButtonUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/RadioButtonUITests.cs
@@ -55,12 +55,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -79,7 +79,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/RootGalleryUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/RootGalleryUITests.cs
index 56398f0010ec..951ef8d3a5ec 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/RootGalleryUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/RootGalleryUITests.cs
@@ -73,7 +73,7 @@ public void VisitEachPage()
{
foreach (var page in rootPages)
{
-#if __WINDOWS__
+#if WINDOWS
App.ScrollDownTo(page.ButtonId, "ChoosePageScrollView");
#else
var scrollViewArea = App.Query(q => q.Marked("ChoosePageScrollView")).First().Rect;
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SearchBarUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SearchBarUITests.cs
index c15fe49de9e0..b56ab41e0b67 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SearchBarUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SearchBarUITests.cs
@@ -42,12 +42,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -66,7 +66,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SliderUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SliderUITests.cs
index 335127cfae76..16c4b585a26e 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SliderUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SliderUITests.cs
@@ -50,12 +50,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -74,7 +74,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/StepperUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/StepperUITests.cs
index 7020b6f3b50b..58aed059744a 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/StepperUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/StepperUITests.cs
@@ -37,7 +37,7 @@ public override void _UnFocus()
{
}
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
#endif
[Category(UITestCategories.UwpIgnore)]
@@ -71,7 +71,7 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -90,7 +90,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SwitchUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SwitchUITests.cs
index ce7aaf859342..ac819e19ca47 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SwitchUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/SwitchUITests.cs
@@ -50,12 +50,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -74,7 +74,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/TimePickerUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/TimePickerUITests.cs
index 785225f67137..d8391fa52b35 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/TimePickerUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/TimePickerUITests.cs
@@ -53,12 +53,12 @@ protected override void FixtureTeardown()
public override void _Opacity() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _IsEnabled() { }
#endif
-#if __ANDROID__ || __IOS__ || __WINDOWS__
+#if __ANDROID__ || __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Rotation() { }
@@ -77,7 +77,7 @@ public override void _TranslationX() { }
public override void _TranslationY() { }
#endif
-#if __IOS__ || __WINDOWS__
+#if __IOS__ || WINDOWS
[Ignore("This is covered by the platform tests")]
public override void _Scale() { }
#endif
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ViewUITests.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ViewUITests.cs
index fc5c149c0786..004790ef6c92 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ViewUITests.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Tests/ViewUITests.cs
@@ -127,7 +127,7 @@ public virtual void _Opacity()
remote.GoTo();
#if __MACOS__
Assert.Inconclusive("needs testing");
-#elif __WINDOWS__
+#elif WINDOWS
Assert.Inconclusive(PleaseInspect);
#else
float opacity = -1f;
@@ -154,7 +154,7 @@ public virtual void _Rotation()
Matrix generatedMatrix = NumericExtensions.CalculateRotationMatrixForDegrees(10, Axis.Z);
Assert.AreEqual(generatedMatrix, rotationMatrix);
#endif
-#if __WINDOWS__
+#if WINDOWS
Assert.Inconclusive(PleaseInspect);
#endif
}
@@ -176,7 +176,7 @@ public virtual void _RotationX()
Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees(33.0f, Axis.X);
Assert.AreEqual(matrix, rotationXMatrix);
#endif
-#if __WINDOWS__
+#if WINDOWS
Assert.Inconclusive(PleaseInspect);
#endif
}
@@ -198,7 +198,7 @@ public virtual void _RotationY()
Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees(10.0f, Axis.Y);
Assert.AreEqual(matrix, rotationYMatrix);
#endif
-#if __WINDOWS__
+#if WINDOWS
Assert.Inconclusive(PleaseInspect);
#endif
}
@@ -213,7 +213,7 @@ public virtual void _Scale()
#if __MACOS__
Assert.Inconclusive("needs testing");
#else
-#if __WINDOWS__
+#if WINDOWS
Assert.Inconclusive(PleaseInspect);
#endif
var scaleMatrix = remote.GetProperty(View.ScaleProperty);
@@ -230,7 +230,7 @@ public virtual void _TranslationX()
{
var remote = new ViewContainerRemote(App, Test.VisualElement.TranslationX, PlatformViewType);
remote.GoTo();
-#if __WINDOWS__
+#if WINDOWS
Assert.Inconclusive(PleaseInspect);
#endif
}
@@ -243,7 +243,7 @@ public virtual void _TranslationY()
{
var remote = new ViewContainerRemote(App, Test.VisualElement.TranslationY, PlatformViewType);
remote.GoTo();
-#if __WINDOWS__
+#if WINDOWS
Assert.Inconclusive(PleaseInspect);
#endif
}
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Utilities/AppExtensions.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Utilities/AppExtensions.cs
index 5f0e86729333..9b60d93aff09 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Utilities/AppExtensions.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Utilities/AppExtensions.cs
@@ -17,7 +17,7 @@ namespace Microsoft.Maui.Controls.Compatibility.UITests
using IApp = global::Xamarin.UITest.IApp;
internal static class AppExtensions
{
-#if __WINDOWS__
+#if WINDOWS
public static void Restart(this IApp app)
{
((ScreenshotConditionalApp)app).Restart();
@@ -25,7 +25,7 @@ public static void Restart(this IApp app)
#endif
public static bool RestartIfAppIsClosed(this IApp app)
{
-#if __WINDOWS__
+#if WINDOWS
return ((ScreenshotConditionalApp)app).RestartIfAppIsClosed();
#else
return false;
@@ -165,7 +165,7 @@ public static void SendAppToBackground(this IApp app, TimeSpan timeSpan)
public static string ReadDatePicker(this IApp app, string marked)
{
-#if __WINDOWS__
+#if WINDOWS
return ((ScreenshotConditionalApp)app).ReadDatePicker(marked).ToString();
#else
return app.WaitForElement(marked)[0].ReadText();
@@ -174,7 +174,7 @@ public static string ReadDatePicker(this IApp app, string marked)
public static string ReadTimePicker(this IApp app, string marked)
{
-#if __WINDOWS__
+#if WINDOWS
return ((ScreenshotConditionalApp)app).ReadTimePicker(marked).ToString();
#else
return app.WaitForElement(marked)[0].ReadText();
diff --git a/src/Compatibility/ControlGallery/src/UITests.Shared/Utilities/Gestures.cs b/src/Compatibility/ControlGallery/src/UITests.Shared/Utilities/Gestures.cs
index 42bbdda9717d..378251dcdd25 100644
--- a/src/Compatibility/ControlGallery/src/UITests.Shared/Utilities/Gestures.cs
+++ b/src/Compatibility/ControlGallery/src/UITests.Shared/Utilities/Gestures.cs
@@ -108,7 +108,7 @@ public static void ActivateContextMenu(this IApp app, string target)
rect.CenterY);
#elif __ANDROID__
app.TouchAndHold(target);
-#elif __WINDOWS__
+#elif WINDOWS
// Since we know we're on desktop for the moment, just use ContextClick. If we get this running
// on actual touch devices at some point, we'll need to check for that and use TouchAndHold
app.Invoke("ContextClick", target);
@@ -123,7 +123,7 @@ public static void DismissContextMenu(this IApp app)
app.TapCoordinates(screenbounds.CenterX, screenbounds.CenterY);
#elif __ANDROID__
app.Back();
-#elif __WINDOWS__
+#elif WINDOWS
var screenbounds = app.RootViewRect();
app.TapCoordinates (screenbounds.CenterX, screenbounds.CenterY);
#endif
diff --git a/src/Compatibility/ControlGallery/src/WinUI/CustomRenderers.cs b/src/Compatibility/ControlGallery/src/WinUI/CustomRenderers.cs
index 923d65d8786b..973315d26946 100644
--- a/src/Compatibility/ControlGallery/src/WinUI/CustomRenderers.cs
+++ b/src/Compatibility/ControlGallery/src/WinUI/CustomRenderers.cs
@@ -11,6 +11,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
[assembly: ExportRenderer(typeof(Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues.Bugzilla42602.TextBoxView), typeof(Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI.TextBoxViewRenderer))]
[assembly: ExportRenderer(typeof(Issue1683.EntryKeyboardFlags), typeof(EntryRendererKeyboardFlags))]
diff --git a/src/Compatibility/ControlGallery/src/WinUI/CustomSwitchRenderer.cs b/src/Compatibility/ControlGallery/src/WinUI/CustomSwitchRenderer.cs
index e79d9fc84e0d..09fef243c15e 100644
--- a/src/Compatibility/ControlGallery/src/WinUI/CustomSwitchRenderer.cs
+++ b/src/Compatibility/ControlGallery/src/WinUI/CustomSwitchRenderer.cs
@@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using WResourceDictionary = Microsoft.UI.Xaml.ResourceDictionary;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
[assembly: ExportRenderer(typeof(CustomSwitch), typeof(CustomSwitchRenderer))]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI
diff --git a/src/Compatibility/ControlGallery/src/WinUI/MainPage.xaml.cs b/src/Compatibility/ControlGallery/src/WinUI/MainPage.xaml.cs
index f5ad33f7eed9..eadf9bdad045 100644
--- a/src/Compatibility/ControlGallery/src/WinUI/MainPage.xaml.cs
+++ b/src/Compatibility/ControlGallery/src/WinUI/MainPage.xaml.cs
@@ -15,6 +15,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI
{
diff --git a/src/Compatibility/ControlGallery/src/WinUI/NavPageOverrideRenderer.cs b/src/Compatibility/ControlGallery/src/WinUI/NavPageOverrideRenderer.cs
index a771bff79e05..93ba48ea5ee1 100644
--- a/src/Compatibility/ControlGallery/src/WinUI/NavPageOverrideRenderer.cs
+++ b/src/Compatibility/ControlGallery/src/WinUI/NavPageOverrideRenderer.cs
@@ -4,6 +4,7 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.Maui.Controls.Internals;
+using Microsoft.Maui.Controls.Platform;
[assembly: ExportRenderer(typeof(NavPageOverrideUWP.CustomNavPageForOverride), typeof(NavPageOverrideRenderer))]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI
diff --git a/src/Compatibility/ControlGallery/src/WinUI/_2489CustomRenderer.cs b/src/Compatibility/ControlGallery/src/WinUI/_2489CustomRenderer.cs
index 994ccd5979ea..dfbc5f7b0fdd 100644
--- a/src/Compatibility/ControlGallery/src/WinUI/_2489CustomRenderer.cs
+++ b/src/Compatibility/ControlGallery/src/WinUI/_2489CustomRenderer.cs
@@ -3,6 +3,7 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
+using Microsoft.Maui.Controls.Platform;
[assembly: ExportRenderer(typeof(Microsoft.Maui.Controls.Page), typeof(_2489CustomRenderer))]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI
diff --git a/src/Compatibility/ControlGallery/src/WinUI/_57114Renderer.cs b/src/Compatibility/ControlGallery/src/WinUI/_57114Renderer.cs
index fa159f262fb6..a47d5becd6a6 100644
--- a/src/Compatibility/ControlGallery/src/WinUI/_57114Renderer.cs
+++ b/src/Compatibility/ControlGallery/src/WinUI/_57114Renderer.cs
@@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
[assembly: ExportRenderer(typeof(Bugzilla57114._57114View), typeof(_57114Renderer))]
diff --git a/src/Compatibility/ControlGallery/src/WinUI/_60122ImageRenderer.cs b/src/Compatibility/ControlGallery/src/WinUI/_60122ImageRenderer.cs
index 4c47665f99d3..bc12e82d9009 100644
--- a/src/Compatibility/ControlGallery/src/WinUI/_60122ImageRenderer.cs
+++ b/src/Compatibility/ControlGallery/src/WinUI/_60122ImageRenderer.cs
@@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
+using Microsoft.Maui.Controls.Platform;
[assembly: ExportRenderer(typeof(Bugzilla60122._60122Image), typeof(_60122ImageRenderer))]
diff --git a/src/Compatibility/ControlGallery/src/WinUI/_9087CustomRenderer.cs b/src/Compatibility/ControlGallery/src/WinUI/_9087CustomRenderer.cs
index 9ae2b122fc22..3c1be43f7518 100644
--- a/src/Compatibility/ControlGallery/src/WinUI/_9087CustomRenderer.cs
+++ b/src/Compatibility/ControlGallery/src/WinUI/_9087CustomRenderer.cs
@@ -1,6 +1,7 @@
using System;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
+using Microsoft.Maui.Controls.Platform;
using static Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues.Issue9087;
[assembly: ExportRenderer(typeof(_9087Label), typeof(_9087CustomRenderer))]
diff --git a/src/Compatibility/ControlGallery/test/WinUI.UITests/WinUI.UITests.csproj b/src/Compatibility/ControlGallery/test/WinUI.UITests/WinUI.UITests.csproj
index 23c9fabcc6fa..b7b9d2a2d44a 100644
--- a/src/Compatibility/ControlGallery/test/WinUI.UITests/WinUI.UITests.csproj
+++ b/src/Compatibility/ControlGallery/test/WinUI.UITests/WinUI.UITests.csproj
@@ -18,7 +18,7 @@
full
false
bin\Debug\
- TRACE;DEBUG;__WINDOWS__;UITEST
+ TRACE;DEBUG;WINDOWS;WINDOWS;UITEST
prompt
4
0114;0108;4014;0649;0169;0168;0219
@@ -27,7 +27,7 @@
pdbonly
true
bin\Release\
- TRACE;__WINDOWS__;UITEST
+ TRACE;WINDOWS;UITEST
prompt
4
0114;0108;4014;0649;0169;0168;0219
diff --git a/src/Compatibility/Core/src/Android/AppCompat/FormsAppCompatActivity.cs b/src/Compatibility/Core/src/Android/AppCompat/FormsAppCompatActivity.cs
index b8368dcdc4c7..e467db2e41e1 100644
--- a/src/Compatibility/Core/src/Android/AppCompat/FormsAppCompatActivity.cs
+++ b/src/Compatibility/Core/src/Android/AppCompat/FormsAppCompatActivity.cs
@@ -241,7 +241,7 @@ void OnCreate(
SetContentView(_layout);
Profile.FramePartition("OnStateChanged");
- Microsoft.Maui.Controls.Application.ClearCurrent();
+ Microsoft.Maui.Controls.Application.Current = null;
_previousState = _currentState;
_currentState = AndroidApplicationLifecycleState.OnCreate;
diff --git a/src/Compatibility/Core/src/Android/RendererToHandlerShim.cs b/src/Compatibility/Core/src/Android/RendererToHandlerShim.cs
index 2f4062aafae9..d4ef1cd24b1c 100644
--- a/src/Compatibility/Core/src/Android/RendererToHandlerShim.cs
+++ b/src/Compatibility/Core/src/Android/RendererToHandlerShim.cs
@@ -22,7 +22,7 @@ public static IViewHandler CreateShim(object renderer)
return new RendererToHandlerShim();
}
- public RendererToHandlerShim() : base(Handlers.ViewHandler.ViewMapper)
+ public RendererToHandlerShim() : base(ViewHandler.ViewMapper)
{
}
diff --git a/src/Compatibility/Core/src/Compatibility-net6.csproj b/src/Compatibility/Core/src/Compatibility-net6.csproj
index 552c28389a8f..72567da76797 100644
--- a/src/Compatibility/Core/src/Compatibility-net6.csproj
+++ b/src/Compatibility/Core/src/Compatibility-net6.csproj
@@ -15,7 +15,7 @@
$(NoWarn);CA1416;CS8305
- $(DefineConstants);WINDOWS_UWP;WINDOWS
+ $(DefineConstants);WINDOWS
win10-x86;win10-x64;win10-arm64
diff --git a/src/Compatibility/Core/src/WinUI/AccessibilityExtensions.cs b/src/Compatibility/Core/src/WinUI/AccessibilityExtensions.cs
index d7dc9c07763e..32b334ac86ab 100644
--- a/src/Compatibility/Core/src/WinUI/AccessibilityExtensions.cs
+++ b/src/Compatibility/Core/src/WinUI/AccessibilityExtensions.cs
@@ -6,91 +6,6 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
public static class AccessibilityExtensions
{
- public static void SetAutomationPropertiesAutomationId(this FrameworkElement Control, string id)
- {
- Control.SetValue(NativeAutomationProperties.AutomationIdProperty, id);
- }
-
- public static string SetAutomationPropertiesName(this FrameworkElement Control, Element Element, string _defaultAutomationPropertiesName = null)
- {
- if (Element == null)
- return _defaultAutomationPropertiesName;
-
- if (_defaultAutomationPropertiesName == null)
- _defaultAutomationPropertiesName = (string)Control.GetValue(NativeAutomationProperties.NameProperty);
-
- var elemValue = (string)Element.GetValue(AutomationProperties.NameProperty);
-
- if (!string.IsNullOrWhiteSpace(elemValue))
- Control.SetValue(NativeAutomationProperties.NameProperty, elemValue);
- else
- Control.SetValue(NativeAutomationProperties.NameProperty, _defaultAutomationPropertiesName);
-
- return _defaultAutomationPropertiesName;
- }
-
- public static AccessibilityView? SetAutomationPropertiesAccessibilityView(this FrameworkElement Control, Element Element, AccessibilityView? _defaultAutomationPropertiesAccessibilityView = null)
- {
- if (Element == null)
- return _defaultAutomationPropertiesAccessibilityView;
-
- if (!_defaultAutomationPropertiesAccessibilityView.HasValue)
- _defaultAutomationPropertiesAccessibilityView = (AccessibilityView)Control.GetValue(NativeAutomationProperties.AccessibilityViewProperty);
-
- var newValue = _defaultAutomationPropertiesAccessibilityView;
-
- var elemValue = (bool?)Element.GetValue(AutomationProperties.IsInAccessibleTreeProperty);
-
- if (elemValue == true)
- newValue = AccessibilityView.Content;
- else if (elemValue == false)
- newValue = AccessibilityView.Raw;
-
- Control.SetValue(NativeAutomationProperties.AccessibilityViewProperty, newValue);
-
- return _defaultAutomationPropertiesAccessibilityView;
-
- }
- public static string SetAutomationPropertiesHelpText(this FrameworkElement Control, Element Element, string _defaultAutomationPropertiesHelpText = null)
- {
- if (Element == null)
- return _defaultAutomationPropertiesHelpText;
-
- if (_defaultAutomationPropertiesHelpText == null)
- _defaultAutomationPropertiesHelpText = (string)Control.GetValue(NativeAutomationProperties.HelpTextProperty);
-
- var elemValue = (string)Element.GetValue(AutomationProperties.HelpTextProperty);
-
- if (!string.IsNullOrWhiteSpace(elemValue))
- Control.SetValue(NativeAutomationProperties.HelpTextProperty, elemValue);
- else
- Control.SetValue(NativeAutomationProperties.HelpTextProperty, _defaultAutomationPropertiesHelpText);
-
- return _defaultAutomationPropertiesHelpText;
- }
-
- public static UIElement SetAutomationPropertiesLabeledBy(this FrameworkElement Control, Element Element, UIElement _defaultAutomationPropertiesLabeledBy = null)
- {
- if (Element == null)
- return _defaultAutomationPropertiesLabeledBy;
-
- if (_defaultAutomationPropertiesLabeledBy == null)
- _defaultAutomationPropertiesLabeledBy = (UIElement)Control.GetValue(NativeAutomationProperties.LabeledByProperty);
-
- var elemValue = (VisualElement)Element.GetValue(AutomationProperties.LabeledByProperty);
-
- var renderer = elemValue?.GetOrCreateRenderer();
-
- var nativeElement = renderer?.GetNativeElement();
-
- if (nativeElement != null)
- Control.SetValue(AutomationProperties.LabeledByProperty, nativeElement);
- else
- Control.SetValue(NativeAutomationProperties.LabeledByProperty, _defaultAutomationPropertiesLabeledBy);
-
- return _defaultAutomationPropertiesLabeledBy;
- }
-
// TODO: This is not having any effect on anything I've tested yet. See if we need it
// after we test the FP and NP w/ back button explicitly enabled.
public static void SetBackButtonTitle(this PageControl Control, Element Element)
@@ -106,7 +21,7 @@ public static void SetBackButtonTitle(this PageControl Control, Element Element)
static string ConcatenateNameAndHint(Element Element)
{
string separator;
-
+
var name = (string)Element.GetValue(AutomationProperties.NameProperty);
var hint = (string)Element.GetValue(AutomationProperties.HelpTextProperty);
@@ -122,17 +37,5 @@ static string ConcatenateNameAndHint(Element Element)
return string.Join(separator, name, hint);
}
-
- internal static void SetAutomationProperties(
- this FrameworkElement frameworkElement,
- Element element,
- string defaultName = null)
- {
- frameworkElement.SetAutomationPropertiesAutomationId(element?.AutomationId);
- frameworkElement.SetAutomationPropertiesName(element, defaultName);
- frameworkElement.SetAutomationPropertiesHelpText(element);
- frameworkElement.SetAutomationPropertiesLabeledBy(element);
- frameworkElement.SetAutomationPropertiesAccessibilityView(element);
- }
}
}
diff --git a/src/Compatibility/Core/src/WinUI/ActivityIndicatorRenderer.cs b/src/Compatibility/Core/src/WinUI/ActivityIndicatorRenderer.cs
index 145c3f2f72db..d29f3fe46077 100644
--- a/src/Compatibility/Core/src/WinUI/ActivityIndicatorRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/ActivityIndicatorRenderer.cs
@@ -1,6 +1,7 @@
using System.ComponentModel;
using Microsoft.Maui.Graphics;
using Microsoft.UI.Xaml;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -55,7 +56,7 @@ void UpdateColor()
}
else
{
- Control.Foreground = color.ToBrush();
+ Control.Foreground = Maui.ColorExtensions.ToNative(color);
}
}
diff --git a/src/Compatibility/Core/src/WinUI/BackgroundTracker.cs b/src/Compatibility/Core/src/WinUI/BackgroundTracker.cs
index 5241cf756486..305b79ceaec2 100644
--- a/src/Compatibility/Core/src/WinUI/BackgroundTracker.cs
+++ b/src/Compatibility/Core/src/WinUI/BackgroundTracker.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
@@ -64,7 +65,7 @@ async void UpdateBackground()
Color backgroundColor = Element.BackgroundColor;
if (!backgroundColor.IsDefault())
{
- element.SetValue(_backgroundProperty, backgroundColor.ToBrush());
+ element.SetValue(_backgroundProperty, Maui.ColorExtensions.ToNative(backgroundColor));
}
else
{
diff --git a/src/Compatibility/Core/src/WinUI/BoxViewBorderRenderer.cs b/src/Compatibility/Core/src/WinUI/BoxViewBorderRenderer.cs
index cf6522a67461..df11e4f84f30 100644
--- a/src/Compatibility/Core/src/WinUI/BoxViewBorderRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/BoxViewBorderRenderer.cs
@@ -3,6 +3,7 @@
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Controls;
using WShape = Microsoft.UI.Xaml.Shapes.Shape;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -66,7 +67,7 @@ protected override void UpdateBackgroundColor()
backgroundColor = Element.BackgroundColor;
}
- Control.Background = backgroundColor.IsDefault() ? null : backgroundColor.ToBrush();
+ Control.Background = backgroundColor.IsDefault() ? null : Maui.ColorExtensions.ToNative(backgroundColor);
}
protected override void UpdateBackground()
@@ -81,7 +82,7 @@ protected override void UpdateBackground()
Color backgroundColor = Element.BackgroundColor;
if (!backgroundColor.IsDefault())
- Control.Background = backgroundColor.ToBrush();
+ Control.Background = Maui.ColorExtensions.ToNative(backgroundColor);
else
{
if (Element.Color.IsDefault())
@@ -97,7 +98,7 @@ void SetColor(Color color)
if (color.IsDefault())
UpdateBackground();
else
- Control.Background = color.ToBrush();
+ Control.Background = Maui.ColorExtensions.ToNative(color);
}
void SetCornerRadius(CornerRadius cornerRadius)
diff --git a/src/Compatibility/Core/src/WinUI/BrushConverter.cs b/src/Compatibility/Core/src/WinUI/BrushConverter.cs
index 27e3c69ccb23..87d0c308132e 100644
--- a/src/Compatibility/Core/src/WinUI/BrushConverter.cs
+++ b/src/Compatibility/Core/src/WinUI/BrushConverter.cs
@@ -1,4 +1,5 @@
using System;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
@@ -10,7 +11,7 @@ public object Convert(object value, Type targetType, object parameter, string la
var brush = value as Brush;
var color = (Color)parameter;
- return Brush.IsNullOrEmpty(brush) ? color.ToBrush() : brush.ToBrush();
+ return Brush.IsNullOrEmpty(brush) ? Maui.ColorExtensions.ToNative(color) : brush.ToBrush();
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
diff --git a/src/Compatibility/Core/src/WinUI/BrushHelpers.cs b/src/Compatibility/Core/src/WinUI/BrushHelpers.cs
index 5d9b9defaa2d..ec5fd42ccec2 100644
--- a/src/Compatibility/Core/src/WinUI/BrushHelpers.cs
+++ b/src/Compatibility/Core/src/WinUI/BrushHelpers.cs
@@ -1,4 +1,5 @@
using System;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
@@ -32,7 +33,7 @@ public static void UpdateColor(Color color, ref WBrush defaultbrush, Func getter, Action setter)
diff --git a/src/Compatibility/Core/src/WinUI/ButtonRenderer.cs b/src/Compatibility/Core/src/WinUI/ButtonRenderer.cs
index bf7322e7acc9..2f428b27dc8e 100644
--- a/src/Compatibility/Core/src/WinUI/ButtonRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/ButtonRenderer.cs
@@ -10,6 +10,7 @@
using WThickness = Microsoft.UI.Xaml.Thickness;
using Microsoft.Maui.Controls.Compatibility.Platform.UAP.Extensions;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -169,14 +170,14 @@ void OnPointerPressed(object sender, RoutedEventArgs e)
void UpdateBackgroundBrush()
{
if (Brush.IsNullOrEmpty(Element.Background))
- Control.BackgroundColor = Element.BackgroundColor.IsNotDefault() ? Element.BackgroundColor.ToBrush() : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBackgroundThemeBrush"];
+ Control.BackgroundColor = Element.BackgroundColor.IsNotDefault() ? Maui.ColorExtensions.ToNative(Element.BackgroundColor) : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBackgroundThemeBrush"];
else
Control.BackgroundColor = Element.Background.ToBrush();
}
void UpdateBorderColor()
{
- Control.BorderBrush = !Element.BorderColor.IsDefault() ? Element.BorderColor.ToBrush() : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBorderThemeBrush"];
+ Control.BorderBrush = !Element.BorderColor.IsDefault() ? Maui.ColorExtensions.ToNative(Element.BorderColor) : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBorderThemeBrush"];
}
void UpdateBorderRadius()
@@ -309,7 +310,7 @@ void UpdateFont()
void UpdateTextColor()
{
- Control.Foreground = Element.TextColor.IsNotDefault() ? Element.TextColor.ToBrush() : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["DefaultTextForegroundThemeBrush"];
+ Control.Foreground = Element.TextColor.IsNotDefault() ? Maui.ColorExtensions.ToNative(Element.TextColor) : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["DefaultTextForegroundThemeBrush"];
}
void UpdatePadding()
diff --git a/src/Compatibility/Core/src/WinUI/CarouselPageRenderer.cs b/src/Compatibility/Core/src/WinUI/CarouselPageRenderer.cs
index d6bc57dcdcae..a175f787f6ae 100644
--- a/src/Compatibility/Core/src/WinUI/CarouselPageRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/CarouselPageRenderer.cs
@@ -6,6 +6,7 @@
using Microsoft.Maui.Controls.Internals;
using WSelectionChangedEventArgs = Microsoft.UI.Xaml.Controls.SelectionChangedEventArgs;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/CheckBoxRenderer.cs b/src/Compatibility/Core/src/WinUI/CheckBoxRenderer.cs
index f04dd8336d0e..9b6c672dfc07 100644
--- a/src/Compatibility/Core/src/WinUI/CheckBoxRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/CheckBoxRenderer.cs
@@ -2,12 +2,13 @@
using Microsoft.Maui.Graphics;
using Microsoft.UI.Xaml;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
public class CheckBoxRenderer : ViewRenderer
{
- static WBrush _tintDefaultBrush = Colors.Blue.ToBrush();
+ static WBrush _tintDefaultBrush = Maui.ColorExtensions.ToNative(Colors.Blue);
bool _disposed = false;
protected virtual FormsCheckBox CreateNativeControl()
diff --git a/src/Compatibility/Core/src/WinUI/CollectionView/CarouselViewRenderer.cs b/src/Compatibility/Core/src/WinUI/CollectionView/CarouselViewRenderer.cs
index fe883432616d..7e275e40bf7d 100644
--- a/src/Compatibility/Core/src/WinUI/CollectionView/CarouselViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/CollectionView/CarouselViewRenderer.cs
@@ -4,6 +4,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Threading.Tasks;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.UI.Composition;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
diff --git a/src/Compatibility/Core/src/WinUI/CollectionView/ItemContentControl.cs b/src/Compatibility/Core/src/WinUI/CollectionView/ItemContentControl.cs
index 6b456229c40b..c40c5d210041 100644
--- a/src/Compatibility/Core/src/WinUI/CollectionView/ItemContentControl.cs
+++ b/src/Compatibility/Core/src/WinUI/CollectionView/ItemContentControl.cs
@@ -5,6 +5,7 @@
using WThickness = Microsoft.UI.Xaml.Thickness;
using WSize = Windows.Foundation.Size;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/CollectionView/ItemsViewRenderer.cs b/src/Compatibility/Core/src/WinUI/CollectionView/ItemsViewRenderer.cs
index 77c98e77896e..ddf1b1b16704 100644
--- a/src/Compatibility/Core/src/WinUI/CollectionView/ItemsViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/CollectionView/ItemsViewRenderer.cs
@@ -12,6 +12,7 @@
using UwpScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollBarVisibility;
using WRect = Windows.Foundation.Rect;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/CollectionView/StructuredItemsViewRenderer.cs b/src/Compatibility/Core/src/WinUI/CollectionView/StructuredItemsViewRenderer.cs
index 6140b80d0129..fbf3f5b9d650 100644
--- a/src/Compatibility/Core/src/WinUI/CollectionView/StructuredItemsViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/CollectionView/StructuredItemsViewRenderer.cs
@@ -1,6 +1,6 @@
using System;
using System.ComponentModel;
-
+using Microsoft.Maui.Controls.Platform;
using Microsoft.UI.Xaml.Controls;
using UWPApp = Microsoft.UI.Xaml.Application;
diff --git a/src/Compatibility/Core/src/WinUI/ColorConverter.cs b/src/Compatibility/Core/src/WinUI/ColorConverter.cs
index 11ced5914ea4..9bd25803bf62 100644
--- a/src/Compatibility/Core/src/WinUI/ColorConverter.cs
+++ b/src/Compatibility/Core/src/WinUI/ColorConverter.cs
@@ -1,4 +1,5 @@
using System;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.UI;
using Windows.UI;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
@@ -15,7 +16,7 @@ public object Convert(object value, Type targetType, object parameter, string la
WBrush defaultBrush = defaultColorKey != null ? (WBrush)Microsoft.UI.Xaml.Application.Current.Resources[defaultColorKey] : new WSolidColorBrush(Colors.Transparent);
- return color.IsDefault() ? defaultBrush : color.ToBrush();
+ return color.IsDefault() ? defaultBrush : Maui.ColorExtensions.ToNative(color);
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
diff --git a/src/Compatibility/Core/src/WinUI/ColorExtensions.cs b/src/Compatibility/Core/src/WinUI/ColorExtensions.cs
deleted file mode 100644
index ca6031e241a0..000000000000
--- a/src/Compatibility/Core/src/WinUI/ColorExtensions.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using Windows.UI;
-using Microsoft.UI;
-using Microsoft.Maui.Graphics;
-using WBrush = Microsoft.UI.Xaml.Media.Brush;
-using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
-{
- public static class ColorExtensions
- {
- public static Windows.UI.Color GetContrastingColor(this Windows.UI.Color color)
- {
- var nThreshold = 105;
- int bgLuminance = Convert.ToInt32(color.R * 0.2 + color.G * 0.7 + color.B * 0.1);
-
- Windows.UI.Color contrastingColor = 255 - bgLuminance < nThreshold ? UI.Colors.Black : UI.Colors.White;
- return contrastingColor;
- }
-
- public static Graphics.Color ToFormsColor(this Windows.UI.Color color)
- {
- return Graphics.Color.FromRgba(color.R, color.G, color.B, color.A);
- }
-
- public static Graphics.Color ToFormsColor(this WSolidColorBrush solidColorBrush)
- {
- return solidColorBrush.Color.ToFormsColor();
- }
-
- public static WBrush ToBrush(this Graphics.Color color)
- {
- return new WSolidColorBrush(color.ToWindowsColor());
- }
-
- public static Windows.UI.Color ToWindowsColor(this Graphics.Color color)
- {
- return Windows.UI.Color.FromArgb((byte)(color.Alpha * 255), (byte)(color.Red * 255), (byte)(color.Green * 255), (byte)(color.Blue * 255));
- }
- }
-}
diff --git a/src/Compatibility/Core/src/WinUI/Compatibility.UAP.csproj b/src/Compatibility/Core/src/WinUI/Compatibility.UAP.csproj
index ea9077fb2854..dc477b358fc7 100644
--- a/src/Compatibility/Core/src/WinUI/Compatibility.UAP.csproj
+++ b/src/Compatibility/Core/src/WinUI/Compatibility.UAP.csproj
@@ -5,7 +5,7 @@
10.0.17134.0
Microsoft.Maui.Controls.Compatibility.UAP
win10-x86;win10-x64;win10-arm64
- $(DefineConstants);DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;UWP_16299;UWP_18362;UWP_17134
+ $(DefineConstants);DEBUG;TRACE;NETFX_CORE;WINDOWS;UWP_16299;UWP_18362;UWP_17134
$(NoWarn);NU5104
diff --git a/src/Compatibility/Core/src/WinUI/DatePickerRenderer.cs b/src/Compatibility/Core/src/WinUI/DatePickerRenderer.cs
index 617062cea71f..8aca5b770239 100644
--- a/src/Compatibility/Core/src/WinUI/DatePickerRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/DatePickerRenderer.cs
@@ -10,6 +10,7 @@
using Microsoft.Maui.Controls.Internals;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -298,7 +299,7 @@ void UpdateMinimumDate()
void UpdateTextColor()
{
Color color = Element.TextColor;
- Control.Foreground = color.IsDefault() ? (_defaultBrush ?? color.ToBrush()) : color.ToBrush();
+ Control.Foreground = color.IsDefault() ? (_defaultBrush ?? Maui.ColorExtensions.ToNative(color)) : Maui.ColorExtensions.ToNative(color);
}
}
}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/WinUI/EditorRenderer.cs b/src/Compatibility/Core/src/WinUI/EditorRenderer.cs
index d3dd0a063610..9d28ee9e421b 100644
--- a/src/Compatibility/Core/src/WinUI/EditorRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/EditorRenderer.cs
@@ -8,6 +8,7 @@
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using Specifics = Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific.InputView;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/EntryRenderer.cs b/src/Compatibility/Core/src/WinUI/EntryRenderer.cs
index ec4f19cb293b..15f53a64cd55 100644
--- a/src/Compatibility/Core/src/WinUI/EntryRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/EntryRenderer.cs
@@ -10,6 +10,7 @@
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using Specifics = Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific.InputView;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/Extensions/ClipExtensions.cs b/src/Compatibility/Core/src/WinUI/Extensions/ClipExtensions.cs
index b2d0af0d0cc0..09a6e5bf528c 100644
--- a/src/Compatibility/Core/src/WinUI/Extensions/ClipExtensions.cs
+++ b/src/Compatibility/Core/src/WinUI/Extensions/ClipExtensions.cs
@@ -6,6 +6,7 @@
using Microsoft.UI.Xaml.Hosting;
using Microsoft.Maui.Controls.Shapes;
using WRectangleGeometry = Microsoft.UI.Xaml.Media.RectangleGeometry;
+using Microsoft.Maui.Controls.Platform;
#if UWP_18362
using WVector2 = System.Numerics.Vector2;
@@ -17,7 +18,7 @@ internal static class ClipExtensions
{
public static void Clip(this FrameworkElement frameworkElement, Geometry geometry)
{
- var wGeometry = geometry.ToWindows();
+ var wGeometry = geometry.ToNative();
if (wGeometry is WRectangleGeometry wRectangleGeometry && frameworkElement.Clip != wRectangleGeometry)
frameworkElement.Clip = wRectangleGeometry;
diff --git a/src/Compatibility/Core/src/WinUI/Extensions/ImageExtensions.cs b/src/Compatibility/Core/src/WinUI/Extensions/ImageExtensions.cs
index 4c8ac8733108..f71cc89d9a0a 100644
--- a/src/Compatibility/Core/src/WinUI/Extensions/ImageExtensions.cs
+++ b/src/Compatibility/Core/src/WinUI/Extensions/ImageExtensions.cs
@@ -11,6 +11,7 @@
using Microsoft.UI.Xaml.Media;
using Microsoft.Maui.Controls.Internals;
using WImageSource = Microsoft.UI.Xaml.Media.ImageSource;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/FileImageSourceHandler.cs b/src/Compatibility/Core/src/WinUI/FileImageSourceHandler.cs
index 8c99ea9fdadb..d0baecfd3e1a 100644
--- a/src/Compatibility/Core/src/WinUI/FileImageSourceHandler.cs
+++ b/src/Compatibility/Core/src/WinUI/FileImageSourceHandler.cs
@@ -5,6 +5,7 @@
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
using IOPath = System.IO.Path;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/FlyoutPageRenderer.cs b/src/Compatibility/Core/src/WinUI/FlyoutPageRenderer.cs
index d2a4abcdd28a..81a2e0641cf5 100644
--- a/src/Compatibility/Core/src/WinUI/FlyoutPageRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/FlyoutPageRenderer.cs
@@ -10,6 +10,7 @@
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using WImageSource = Microsoft.UI.Xaml.Media.ImageSource;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -184,7 +185,7 @@ protected virtual void OnElementChanged(ElementChangedEventArgs e)
_defaultAutomationPropertiesName = Control.SetAutomationPropertiesName(Element, _defaultAutomationPropertiesName);
_defaultAutomationPropertiesHelpText = Control.SetAutomationPropertiesHelpText(Element, _defaultAutomationPropertiesHelpText);
- _defaultAutomationPropertiesLabeledBy = Control.SetAutomationPropertiesLabeledBy(Element, _defaultAutomationPropertiesLabeledBy);
+ _defaultAutomationPropertiesLabeledBy = Control.SetAutomationPropertiesLabeledBy(Element, Element.Handler?.MauiContext ?? Forms.MauiContext, _defaultAutomationPropertiesLabeledBy);
_defaultAutomationPropertiesAccessibilityView = Control.SetAutomationPropertiesAccessibilityView(Element, _defaultAutomationPropertiesAccessibilityView);
}
}
@@ -212,7 +213,7 @@ protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEv
else if (e.PropertyName == AutomationProperties.HelpTextProperty.PropertyName)
_defaultAutomationPropertiesHelpText = Control.SetAutomationPropertiesHelpText(Element, _defaultAutomationPropertiesHelpText);
else if (e.PropertyName == AutomationProperties.LabeledByProperty.PropertyName)
- _defaultAutomationPropertiesLabeledBy = Control.SetAutomationPropertiesLabeledBy(Element, _defaultAutomationPropertiesLabeledBy);
+ _defaultAutomationPropertiesLabeledBy = Control.SetAutomationPropertiesLabeledBy(Element, Element.Handler?.MauiContext ?? Forms.MauiContext, _defaultAutomationPropertiesLabeledBy);
else if (e.PropertyName == AutomationProperties.IsInAccessibleTreeProperty.PropertyName)
_defaultAutomationPropertiesAccessibilityView = Control.SetAutomationPropertiesAccessibilityView(Element, _defaultAutomationPropertiesAccessibilityView);
}
diff --git a/src/Compatibility/Core/src/WinUI/FontImageSourceHandler.cs b/src/Compatibility/Core/src/WinUI/FontImageSourceHandler.cs
index c32cb67fdf19..3c22f09eb81f 100644
--- a/src/Compatibility/Core/src/WinUI/FontImageSourceHandler.cs
+++ b/src/Compatibility/Core/src/WinUI/FontImageSourceHandler.cs
@@ -4,6 +4,7 @@
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Text;
using Microsoft.Graphics.Canvas.UI.Xaml;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
@@ -68,7 +69,7 @@ public sealed class FontImageSourceHandler : IImageSourceHandler, IIconElementHa
{
Glyph = fontImageSource.Glyph,
FontSize = fontImageSource.Size,
- Foreground = fontImageSource.Color.ToBrush()
+ Foreground = Maui.ColorExtensions.ToNative(fontImageSource.Color)
};
var uwpFontFamily = fontImageSource.FontFamily.ToFontFamily();
@@ -90,7 +91,7 @@ public sealed class FontImageSourceHandler : IImageSourceHandler, IIconElementHa
{
Glyph = fontImageSource.Glyph,
FontSize = fontImageSource.Size,
- Foreground = fontImageSource.Color.ToBrush()
+ Foreground = Maui.ColorExtensions.ToNative(fontImageSource.Color)
};
var uwpFontFamily = fontImageSource.FontFamily.ToFontFamily();
diff --git a/src/Compatibility/Core/src/WinUI/Forms.cs b/src/Compatibility/Core/src/WinUI/Forms.cs
index bddacd4e10ac..35cbf8e03dd3 100644
--- a/src/Compatibility/Core/src/WinUI/Forms.cs
+++ b/src/Compatibility/Core/src/WinUI/Forms.cs
@@ -66,15 +66,12 @@ static void SetupInit(
Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim);
var accent = (WSolidColorBrush)Microsoft.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"];
- KnownColor.SetAccent(accent.ToFormsColor());
+ KnownColor.SetAccent(accent.ToColor());
if (!IsInitialized)
{
-#if !UWP_16299
Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m)));
-#else
- Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c)));
-#endif
+
}
if (!UI.Xaml.Application.Current.Resources.ContainsKey("RootContainerStyle"))
diff --git a/src/Compatibility/Core/src/WinUI/FormsButton.cs b/src/Compatibility/Core/src/WinUI/FormsButton.cs
index baf56bbe0a52..32351437ad04 100644
--- a/src/Compatibility/Core/src/WinUI/FormsButton.cs
+++ b/src/Compatibility/Core/src/WinUI/FormsButton.cs
@@ -1,3 +1,4 @@
+using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
diff --git a/src/Compatibility/Core/src/WinUI/FormsRadioButton.cs b/src/Compatibility/Core/src/WinUI/FormsRadioButton.cs
index 2abaa58d92eb..1b0888cdf1e7 100644
--- a/src/Compatibility/Core/src/WinUI/FormsRadioButton.cs
+++ b/src/Compatibility/Core/src/WinUI/FormsRadioButton.cs
@@ -1,3 +1,4 @@
+using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
using Microsoft.UI.Xaml;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
diff --git a/src/Compatibility/Core/src/WinUI/FrameRenderer.cs b/src/Compatibility/Core/src/WinUI/FrameRenderer.cs
index 36d23a3094ea..46c3fe094118 100644
--- a/src/Compatibility/Core/src/WinUI/FrameRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/FrameRenderer.cs
@@ -3,6 +3,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Controls;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -67,7 +68,7 @@ protected override void UpdateBackgroundColor()
if (Control != null)
{
Control.Background = backgroundColor.IsDefault() ?
- new Microsoft.UI.Xaml.Media.SolidColorBrush((Windows.UI.Color)Resources["SystemAltHighColor"]) : backgroundColor.ToBrush();
+ new Microsoft.UI.Xaml.Media.SolidColorBrush((Windows.UI.Color)Resources["SystemAltHighColor"]) : Maui.ColorExtensions.ToNative(backgroundColor);
}
}
@@ -80,7 +81,7 @@ protected override void UpdateBackground()
{
if (Brush.IsNullOrEmpty(background))
Control.Background = backgroundColor.IsDefault() ?
- new Microsoft.UI.Xaml.Media.SolidColorBrush((Windows.UI.Color)Resources["SystemAltHighColor"]) : backgroundColor.ToBrush();
+ new Microsoft.UI.Xaml.Media.SolidColorBrush((Windows.UI.Color)Resources["SystemAltHighColor"]) : Maui.ColorExtensions.ToNative(backgroundColor);
else
Control.Background = background.ToBrush();
}
@@ -99,12 +100,12 @@ void UpdateBorder()
{
if (Element.BorderColor.IsNotDefault())
{
- Control.BorderBrush = Element.BorderColor.ToBrush();
+ Control.BorderBrush = Maui.ColorExtensions.ToNative(Element.BorderColor);
Control.BorderThickness = WinUIHelpers.CreateThickness(1);
}
else
{
- Control.BorderBrush = new Color(0, 0, 0, 0).ToBrush();
+ Control.BorderBrush = Maui.ColorExtensions.ToNative(new Color(0, 0, 0, 0));
}
}
diff --git a/src/Compatibility/Core/src/WinUI/HandlerToRendererShim.cs b/src/Compatibility/Core/src/WinUI/HandlerToRendererShim.cs
index 2c1a59c59666..6d5796715544 100644
--- a/src/Compatibility/Core/src/WinUI/HandlerToRendererShim.cs
+++ b/src/Compatibility/Core/src/WinUI/HandlerToRendererShim.cs
@@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.UI.Xaml;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility
{
diff --git a/src/Compatibility/Core/src/WinUI/IDontGetFocus.cs b/src/Compatibility/Core/src/WinUI/IDontGetFocus.cs
deleted file mode 100644
index 58311370770a..000000000000
--- a/src/Compatibility/Core/src/WinUI/IDontGetFocus.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
-{
- public interface IDontGetFocus
- {
- }
-}
diff --git a/src/Compatibility/Core/src/WinUI/ITabStopOnDescendants.cs b/src/Compatibility/Core/src/WinUI/ITabStopOnDescendants.cs
deleted file mode 100644
index 0f6dcbef0a93..000000000000
--- a/src/Compatibility/Core/src/WinUI/ITabStopOnDescendants.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
-{
- public interface ITabStopOnDescendants: IDontGetFocus
- {
- }
-}
diff --git a/src/Compatibility/Core/src/WinUI/IVisualElementRenderer.cs b/src/Compatibility/Core/src/WinUI/IVisualElementRenderer.cs
index 7ca4eec57cc3..45d7a501bac2 100644
--- a/src/Compatibility/Core/src/WinUI/IVisualElementRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/IVisualElementRenderer.cs
@@ -1,4 +1,5 @@
using System;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.UI.Xaml;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
diff --git a/src/Compatibility/Core/src/WinUI/ImageButtonRenderer.cs b/src/Compatibility/Core/src/WinUI/ImageButtonRenderer.cs
index 9998c7fa6e87..fe413103b3d8 100644
--- a/src/Compatibility/Core/src/WinUI/ImageButtonRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/ImageButtonRenderer.cs
@@ -10,6 +10,7 @@
using WStretch = Microsoft.UI.Xaml.Media.Stretch;
using WThickness = Microsoft.UI.Xaml.Thickness;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -251,14 +252,14 @@ void OnPointerPressed(object sender, RoutedEventArgs e)
void UpdateImageButtonBackground()
{
if (Brush.IsNullOrEmpty(Element.Background))
- Control.BackgroundColor = Element.BackgroundColor.IsNotDefault() ? Element.BackgroundColor.ToBrush() : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBackgroundThemeBrush"];
+ Control.BackgroundColor = Element.BackgroundColor.IsNotDefault() ? Maui.ColorExtensions.ToNative(Element.BackgroundColor) : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBackgroundThemeBrush"];
else
Control.BackgroundColor = Element.Background.ToBrush();
}
void UpdateBorderColor()
{
- Control.BorderBrush = Element.BorderColor.IsNotDefault() ? Element.BorderColor.ToBrush() : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBorderThemeBrush"];
+ Control.BorderBrush = Element.BorderColor.IsNotDefault() ? Maui.ColorExtensions.ToNative(Element.BorderColor) : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBorderThemeBrush"];
}
void UpdateBorderRadius()
diff --git a/src/Compatibility/Core/src/WinUI/ImageElementManager.cs b/src/Compatibility/Core/src/WinUI/ImageElementManager.cs
index f34e1d1fcb0c..65da9d3f0ea2 100644
--- a/src/Compatibility/Core/src/WinUI/ImageElementManager.cs
+++ b/src/Compatibility/Core/src/WinUI/ImageElementManager.cs
@@ -6,6 +6,7 @@
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using WStretch = Microsoft.UI.Xaml.Media.Stretch;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/ImageRenderer.cs b/src/Compatibility/Core/src/WinUI/ImageRenderer.cs
index 4b7b6184198f..e5ab8770d918 100644
--- a/src/Compatibility/Core/src/WinUI/ImageRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/ImageRenderer.cs
@@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Microsoft.UI.Xaml;
using Microsoft.Maui.Controls.Internals;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/IndicatorViewRenderer.cs b/src/Compatibility/Core/src/WinUI/IndicatorViewRenderer.cs
index d066210c1bad..8b55ff481017 100644
--- a/src/Compatibility/Core/src/WinUI/IndicatorViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/IndicatorViewRenderer.cs
@@ -8,6 +8,7 @@
using WEllipse = Microsoft.UI.Xaml.Shapes.Ellipse;
using WRectangle = Microsoft.UI.Xaml.Shapes.Rectangle;
using WShape = Microsoft.UI.Xaml.Shapes.Shape;
+using Microsoft.Maui.Controls.Platform;
using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
diff --git a/src/Compatibility/Core/src/WinUI/LabelRenderer.cs b/src/Compatibility/Core/src/WinUI/LabelRenderer.cs
index 8d09894bead3..26dbea5d3cb6 100644
--- a/src/Compatibility/Core/src/WinUI/LabelRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/LabelRenderer.cs
@@ -15,6 +15,7 @@
using WRect = Windows.Foundation.Rect;
using WThickness = Microsoft.UI.Xaml.Thickness;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -25,7 +26,7 @@ public static Run ToRun(this Span span)
var run = new Run { Text = span.Text ?? string.Empty };
if (span.TextColor.IsNotDefault())
- run.Foreground = span.TextColor.ToBrush();
+ run.Foreground = Maui.ColorExtensions.ToNative(span.TextColor);
if (!span.IsDefault())
run.ApplyFont(span);
@@ -247,7 +248,7 @@ void UpdateColor(TextBlock textBlock)
Label label = Element;
if (label != null && label.TextColor.IsNotDefault())
{
- textBlock.Foreground = label.TextColor.ToBrush();
+ textBlock.Foreground = Maui.ColorExtensions.ToNative(label.TextColor);
}
else
{
diff --git a/src/Compatibility/Core/src/WinUI/LayoutRenderer.cs b/src/Compatibility/Core/src/WinUI/LayoutRenderer.cs
index 6e3e1b0584a6..ade47c3f9a25 100644
--- a/src/Compatibility/Core/src/WinUI/LayoutRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/LayoutRenderer.cs
@@ -6,6 +6,7 @@
using WRect = Windows.Foundation.Rect;
using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;
using Microsoft.UI;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/ListViewRenderer.cs b/src/Compatibility/Core/src/WinUI/ListViewRenderer.cs
index 4ad43768a022..fab01fb474ca 100644
--- a/src/Compatibility/Core/src/WinUI/ListViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/ListViewRenderer.cs
@@ -21,6 +21,7 @@
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
using Specifics = Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific.ListView;
using System.Collections.ObjectModel;
+using Microsoft.Maui.Controls.Platform;
using UwpScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollBarVisibility;
using WSelectionChangedEventArgs = Microsoft.UI.Xaml.Controls.SelectionChangedEventArgs;
diff --git a/src/Compatibility/Core/src/WinUI/MasterBackgroundConverter.cs b/src/Compatibility/Core/src/WinUI/MasterBackgroundConverter.cs
index 63b427b2e529..4be2b83c36bf 100644
--- a/src/Compatibility/Core/src/WinUI/MasterBackgroundConverter.cs
+++ b/src/Compatibility/Core/src/WinUI/MasterBackgroundConverter.cs
@@ -38,7 +38,7 @@ public object Convert(object value, Type targetType, object parameter, string la
brush = value as WSolidColorBrush;
if (brush != null)
{
- Maui.Graphics.Color color = brush.ToFormsColor();
+ Maui.Graphics.Color color = brush.ToColor();
double delta = Shift;
if (color.GetLuminosity() > .6)
diff --git a/src/Compatibility/Core/src/WinUI/NativeViewWrapperRenderer.cs b/src/Compatibility/Core/src/WinUI/NativeViewWrapperRenderer.cs
index cb9e2f2dc636..b13e90946da3 100644
--- a/src/Compatibility/Core/src/WinUI/NativeViewWrapperRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/NativeViewWrapperRenderer.cs
@@ -1,5 +1,6 @@
using Microsoft.UI.Xaml;
using Microsoft.Maui.Controls.Internals;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/NavigationPageRenderer.cs b/src/Compatibility/Core/src/WinUI/NavigationPageRenderer.cs
index a014c698006c..07d072672d10 100644
--- a/src/Compatibility/Core/src/WinUI/NavigationPageRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/NavigationPageRenderer.cs
@@ -16,6 +16,7 @@
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using WImageSource = Microsoft.UI.Xaml.Media.ImageSource;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -281,7 +282,7 @@ WBrush GetBarBackgroundColorBrush()
if (Element.BarBackgroundColor.IsDefault() && defaultColor != null)
return (WBrush)defaultColor;
- return Element.BarBackgroundColor.ToBrush();
+ return Maui.ColorExtensions.ToNative(Element.BarBackgroundColor);
}
WBrush GetBarBackgroundBrush()
@@ -303,7 +304,7 @@ WBrush GetBarForegroundBrush()
object defaultColor = Microsoft.UI.Xaml.Application.Current.Resources["ApplicationForegroundThemeBrush"];
if (Element.BarTextColor.IsDefault())
return (WBrush)defaultColor;
- return Element.BarTextColor.ToBrush();
+ return Maui.ColorExtensions.ToNative(Element.BarTextColor);
}
bool GetIsNavBarPossible()
diff --git a/src/Compatibility/Core/src/WinUI/PageRenderer.cs b/src/Compatibility/Core/src/WinUI/PageRenderer.cs
index 21d142f696c8..7cd725c8c2bd 100644
--- a/src/Compatibility/Core/src/WinUI/PageRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/PageRenderer.cs
@@ -4,6 +4,7 @@
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Controls;
using System;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/PickerRenderer.cs b/src/Compatibility/Core/src/WinUI/PickerRenderer.cs
index 3100a5005b87..ad0185a7c82d 100644
--- a/src/Compatibility/Core/src/WinUI/PickerRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/PickerRenderer.cs
@@ -8,6 +8,7 @@
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using WSelectionChangedEventArgs = Microsoft.UI.Xaml.Controls.SelectionChangedEventArgs;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -218,7 +219,7 @@ void UpdateSelectedIndex()
void UpdateTextColor()
{
Color color = Element.TextColor;
- Control.Foreground = color.IsDefault() ? (_defaultBrush ?? color.ToBrush()) : color.ToBrush();
+ Control.Foreground = color.IsDefault() ? (_defaultBrush ?? Maui.ColorExtensions.ToNative(color)) : Maui.ColorExtensions.ToNative(color);
}
void UpdateTitle()
diff --git a/src/Compatibility/Core/src/WinUI/Platform.cs b/src/Compatibility/Core/src/WinUI/Platform.cs
index 1039d5c37181..04a2022fd2c5 100644
--- a/src/Compatibility/Core/src/WinUI/Platform.cs
+++ b/src/Compatibility/Core/src/WinUI/Platform.cs
@@ -11,6 +11,7 @@
using WFlowDirection = Microsoft.UI.Xaml.FlowDirection;
using WImage = Microsoft.UI.Xaml.Controls.Image;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -146,11 +147,11 @@ internal Platform(Microsoft.UI.Xaml.Window page)
UpdateBounds();
InitializeStatusBar();
-
- // TODO WINUI
- //SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
+
+ if(!NativeVersion.IsDesktop)
+ SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
- // TODO WINUI
+ // TODO WINUI: This event is only available on UWP
// Microsoft.UI.Xaml.Application.Current.Resuming += OnResumingAsync;
}
@@ -555,14 +556,16 @@ internal async Task UpdateToolbarItems()
button.Content = img;
}
- // WINUUI FIX
+ // TODO WINUI FIX
//button.Command = new MenuItemCommand(item);
button.DataContext = item;
button.SetValue(NativeAutomationProperties.AutomationIdProperty, item.AutomationId);
button.SetAutomationPropertiesName(item);
button.SetAutomationPropertiesAccessibilityView(item);
button.SetAutomationPropertiesHelpText(item);
- button.SetAutomationPropertiesLabeledBy(item);
+
+ // TODO MAUI
+ button.SetAutomationPropertiesLabeledBy(item, null);
ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order;
if (order == ToolbarItemOrder.Primary)
diff --git a/src/Compatibility/Core/src/WinUI/PointCollectionExtensions.cs b/src/Compatibility/Core/src/WinUI/PointCollectionExtensions.cs
index c9047a6df2b2..030a654a6e10 100644
--- a/src/Compatibility/Core/src/WinUI/PointCollectionExtensions.cs
+++ b/src/Compatibility/Core/src/WinUI/PointCollectionExtensions.cs
@@ -1,7 +1,7 @@
using Microsoft.Maui.Controls.Shapes;
using Microsoft.Maui.Graphics;
-#if WINDOWS_UWP
+#if WINDOWS
using WPoint = Windows.Foundation.Point;
using WPointCollection = Microsoft.UI.Xaml.Media.PointCollection;
diff --git a/src/Compatibility/Core/src/WinUI/PointExtensions.cs b/src/Compatibility/Core/src/WinUI/PointExtensions.cs
deleted file mode 100644
index 8e35f0134131..000000000000
--- a/src/Compatibility/Core/src/WinUI/PointExtensions.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-#if WINDOWS_UWP
-using Microsoft.Maui.Graphics;
-using WPoint = Windows.Foundation.Point;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
-#else
-using WPoint = System.Windows.Point;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.WPF
-#endif
-{
- public static class PointExtensions
- {
- public static WPoint ToWindows(this Point point)
- {
- return new WPoint(point.X, point.Y);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/WinUI/ProgressBarRenderer.cs b/src/Compatibility/Core/src/WinUI/ProgressBarRenderer.cs
index e94c0a97c74b..19f0dfb5c345 100644
--- a/src/Compatibility/Core/src/WinUI/ProgressBarRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/ProgressBarRenderer.cs
@@ -3,6 +3,7 @@
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -82,7 +83,7 @@ void UpdateProgressColor()
}
else
{
- Control.Foreground = color.ToBrush();
+ Control.Foreground = Maui.ColorExtensions.ToNative(color);
}
}
diff --git a/src/Compatibility/Core/src/WinUI/Properties/AssemblyInfo.cs b/src/Compatibility/Core/src/WinUI/Properties/AssemblyInfo.cs
index 0420d1c75567..fbf59ecd6945 100644
--- a/src/Compatibility/Core/src/WinUI/Properties/AssemblyInfo.cs
+++ b/src/Compatibility/Core/src/WinUI/Properties/AssemblyInfo.cs
@@ -1,6 +1,7 @@
using System.Reflection;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Controls.Shapes;
using Rectangle = Microsoft.Maui.Controls.Shapes.Rectangle;
diff --git a/src/Compatibility/Core/src/WinUI/RadioButtonRenderer.cs b/src/Compatibility/Core/src/WinUI/RadioButtonRenderer.cs
index 6d3e2e7a3fef..b9058df086c9 100644
--- a/src/Compatibility/Core/src/WinUI/RadioButtonRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/RadioButtonRenderer.cs
@@ -5,6 +5,7 @@
using WThickness = Microsoft.UI.Xaml.Thickness;
using static Microsoft.Maui.Controls.Compatibility.Platform.UWP.ViewToRendererConverter;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -145,14 +146,14 @@ void OnRadioButtonCheckedOrUnchecked(object sender, RoutedEventArgs e)
void UpdateBackgroundBrush()
{
if (Brush.IsNullOrEmpty(Element.Background))
- Control.BackgroundColor = Element.BackgroundColor.IsNotDefault() ? Element.BackgroundColor.ToBrush() : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBackgroundThemeBrush"];
+ Control.BackgroundColor = Element.BackgroundColor.IsNotDefault() ? Maui.ColorExtensions.ToNative(Element.BackgroundColor) : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBackgroundThemeBrush"];
else
Control.BackgroundColor = Element.Background.ToBrush();
}
void UpdateBorderColor()
{
- Control.BorderBrush = Element.BorderColor.IsNotDefault() ? Element.BorderColor.ToBrush() : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBorderThemeBrush"];
+ Control.BorderBrush = Element.BorderColor.IsNotDefault() ? Maui.ColorExtensions.ToNative(Element.BorderColor) : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["ButtonBorderThemeBrush"];
}
void UpdateBorderRadius()
@@ -196,7 +197,7 @@ void UpdateFont()
void UpdateTextColor()
{
- Control.Foreground = Element.TextColor.IsNotDefault() ? Element.TextColor.ToBrush() : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["DefaultTextForegroundThemeBrush"];
+ Control.Foreground = Element.TextColor.IsNotDefault() ? Maui.ColorExtensions.ToNative(Element.TextColor) : (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["DefaultTextForegroundThemeBrush"];
}
void UpdatePadding()
diff --git a/src/Compatibility/Core/src/WinUI/RefreshViewRenderer.cs b/src/Compatibility/Core/src/WinUI/RefreshViewRenderer.cs
index f759d854f95a..d73e341a3655 100644
--- a/src/Compatibility/Core/src/WinUI/RefreshViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/RefreshViewRenderer.cs
@@ -9,6 +9,7 @@
using Specifics = Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific.RefreshView;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -120,9 +121,9 @@ protected override void UpdateBackgroundColor()
return;
if (Element.BackgroundColor.IsNotDefault())
- Control.Visualizer.Background = Element.BackgroundColor.ToBrush();
+ Control.Visualizer.Background = Maui.ColorExtensions.ToNative(Element.BackgroundColor);
else
- Control.Visualizer.Background = Colors.White.ToBrush();
+ Control.Visualizer.Background = Maui.ColorExtensions.ToNative(Colors.White);
}
void UpdateContent()
@@ -160,7 +161,7 @@ void UpdateColors()
return;
Control.Visualizer.Foreground = Element.RefreshColor.IsNotDefault()
- ? Element.RefreshColor.ToBrush()
+ ? Maui.ColorExtensions.ToNative(Element.RefreshColor)
: (WBrush)Microsoft.UI.Xaml.Application.Current.Resources["DefaultTextForegroundThemeBrush"];
UpdateBackgroundColor();
diff --git a/src/Compatibility/Core/src/WinUI/RendererToHandlerShim.cs b/src/Compatibility/Core/src/WinUI/RendererToHandlerShim.cs
index 9e24462c3ca1..58bcf88985d2 100644
--- a/src/Compatibility/Core/src/WinUI/RendererToHandlerShim.cs
+++ b/src/Compatibility/Core/src/WinUI/RendererToHandlerShim.cs
@@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.UI.Xaml;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility
{
diff --git a/src/Compatibility/Core/src/WinUI/ScrollViewRenderer.cs b/src/Compatibility/Core/src/WinUI/ScrollViewRenderer.cs
index 6dae05612797..8489dce9823b 100644
--- a/src/Compatibility/Core/src/WinUI/ScrollViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/ScrollViewRenderer.cs
@@ -6,6 +6,7 @@
using WRect = Windows.Foundation.Rect;
using UwpScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollBarVisibility;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/SearchBarRenderer.cs b/src/Compatibility/Core/src/WinUI/SearchBarRenderer.cs
index d49f0b7edc87..7f0d9a7c89c3 100644
--- a/src/Compatibility/Core/src/WinUI/SearchBarRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/SearchBarRenderer.cs
@@ -7,6 +7,7 @@
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using Specifics = Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific.SearchBar;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -188,7 +189,7 @@ void UpdateCancelButtonColor()
else
{
// Determine whether the background should be black or white (in order to make the foreground color visible)
- var bcolor = cancelColor.ToWindowsColor().GetContrastingColor().ToFormsColor();
+ var bcolor = cancelColor.ToWindowsColor().GetContrastingColor().ToColor();
BrushHelpers.UpdateColor(bcolor, ref _defaultDeleteButtonBackgroundColorBrush,
() => _cancelButton.BackgroundBrush, brush => _cancelButton.BackgroundBrush = brush);
}
@@ -324,7 +325,7 @@ protected override void UpdateBackgroundColor()
if (!backgroundColor.IsDefault())
{
- _queryTextBox.Background = backgroundColor.ToBrush();
+ _queryTextBox.Background = Maui.ColorExtensions.ToNative(backgroundColor);
}
else
{
diff --git a/src/Compatibility/Core/src/WinUI/Shapes/EllipseRenderer.cs b/src/Compatibility/Core/src/WinUI/Shapes/EllipseRenderer.cs
index ca88dff12a98..eebef955337a 100644
--- a/src/Compatibility/Core/src/WinUI/Shapes/EllipseRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shapes/EllipseRenderer.cs
@@ -1,6 +1,7 @@
using Microsoft.Maui.Controls.Shapes;
+using Microsoft.Maui.Controls.Platform;
-#if WINDOWS_UWP
+#if WINDOWS
using WEllipse = Microsoft.UI.Xaml.Shapes.Ellipse;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
diff --git a/src/Compatibility/Core/src/WinUI/Shapes/LineRenderer.cs b/src/Compatibility/Core/src/WinUI/Shapes/LineRenderer.cs
index 9dfe376e930c..1aeb68b77b92 100644
--- a/src/Compatibility/Core/src/WinUI/Shapes/LineRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shapes/LineRenderer.cs
@@ -1,7 +1,8 @@
using System.ComponentModel;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Controls.Shapes;
-#if WINDOWS_UWP
+#if WINDOWS
using WLine = Microsoft.UI.Xaml.Shapes.Line;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
diff --git a/src/Compatibility/Core/src/WinUI/Shapes/PathRenderer.cs b/src/Compatibility/Core/src/WinUI/Shapes/PathRenderer.cs
index bebc33b16948..ea981f0e6c15 100644
--- a/src/Compatibility/Core/src/WinUI/Shapes/PathRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shapes/PathRenderer.cs
@@ -1,7 +1,8 @@
using System.ComponentModel;
using Path = Microsoft.Maui.Controls.Shapes.Path;
+using Microsoft.Maui.Controls.Platform;
-#if WINDOWS_UWP
+#if WINDOWS
using WPath = Microsoft.UI.Xaml.Shapes.Path;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
@@ -41,7 +42,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
void UpdateData()
{
- Control.Data = Element.Data.ToWindows();
+ Control.Data = Element.Data.ToNative();
}
void UpdateRenderTransform()
diff --git a/src/Compatibility/Core/src/WinUI/Shapes/PolygonRenderer.cs b/src/Compatibility/Core/src/WinUI/Shapes/PolygonRenderer.cs
index 5a2c0d47aa3c..2e296468311e 100644
--- a/src/Compatibility/Core/src/WinUI/Shapes/PolygonRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shapes/PolygonRenderer.cs
@@ -1,8 +1,9 @@
using System.ComponentModel;
using Microsoft.Maui.Controls.Shapes;
using System.Collections.Specialized;
+using Microsoft.Maui.Controls.Platform;
-#if WINDOWS_UWP
+#if WINDOWS
using WFillRule = Microsoft.UI.Xaml.Media.FillRule;
using WPolygon = Microsoft.UI.Xaml.Shapes.Polygon;
diff --git a/src/Compatibility/Core/src/WinUI/Shapes/PolylineRenderer.cs b/src/Compatibility/Core/src/WinUI/Shapes/PolylineRenderer.cs
index 862909fb7ca1..8ef1f35f0bc9 100644
--- a/src/Compatibility/Core/src/WinUI/Shapes/PolylineRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shapes/PolylineRenderer.cs
@@ -1,8 +1,9 @@
using System.ComponentModel;
using Microsoft.Maui.Controls.Shapes;
using System.Collections.Specialized;
+using Microsoft.Maui.Controls.Platform;
-#if WINDOWS_UWP
+#if WINDOWS
using WFillRule = Microsoft.UI.Xaml.Media.FillRule;
using WPolyline = Microsoft.UI.Xaml.Shapes.Polyline;
diff --git a/src/Compatibility/Core/src/WinUI/Shapes/RectangleRenderer.cs b/src/Compatibility/Core/src/WinUI/Shapes/RectangleRenderer.cs
index 328db4023f7c..e838de0dfa91 100644
--- a/src/Compatibility/Core/src/WinUI/Shapes/RectangleRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shapes/RectangleRenderer.cs
@@ -1,7 +1,8 @@
using System.ComponentModel;
+using Microsoft.Maui.Controls.Platform;
using FormsRectangle = Microsoft.Maui.Controls.Shapes.Rectangle;
-#if WINDOWS_UWP
+#if WINDOWS
using WRectangle = Microsoft.UI.Xaml.Shapes.Rectangle;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
diff --git a/src/Compatibility/Core/src/WinUI/Shapes/ShapeRenderer.cs b/src/Compatibility/Core/src/WinUI/Shapes/ShapeRenderer.cs
index e120fc2b8f3a..9be91b9227ff 100644
--- a/src/Compatibility/Core/src/WinUI/Shapes/ShapeRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shapes/ShapeRenderer.cs
@@ -2,8 +2,9 @@
using System.ComponentModel;
using Shape = Microsoft.Maui.Controls.Shapes.Shape;
using Microsoft.Maui.Controls.Shapes;
+using Microsoft.Maui.Controls.Platform;
-#if WINDOWS_UWP
+#if WINDOWS
using Microsoft.UI.Xaml;
using WDoubleCollection = Microsoft.UI.Xaml.Media.DoubleCollection;
using WPenLineCap = Microsoft.UI.Xaml.Media.PenLineCap;
@@ -74,7 +75,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
UpdateStrokeMiterLimit();
}
-#if !WINDOWS_UWP
+#if !WINDOWS
new
#endif
void UpdateHeight()
@@ -82,7 +83,7 @@ void UpdateHeight()
Control.Height = Math.Max(Element.Height, 0);
}
-#if !WINDOWS_UWP
+#if !WINDOWS
new
#endif
void UpdateWidth()
diff --git a/src/Compatibility/Core/src/WinUI/Shell/ShellItemRenderer.cs b/src/Compatibility/Core/src/WinUI/Shell/ShellItemRenderer.cs
index ab541b8e99a6..1303de7cb14e 100644
--- a/src/Compatibility/Core/src/WinUI/Shell/ShellItemRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shell/ShellItemRenderer.cs
@@ -17,6 +17,7 @@
using Microsoft.UI.Xaml.Media;
using UwpApplication = Microsoft.UI.Xaml.Application;
using UwpSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -167,7 +168,7 @@ void UpdateBottomBar()
if (!fontImageSource.Color.IsDefault())
{
- icon.Foreground = fontImageSource.Color.ToBrush();
+ icon.Foreground = Maui.ColorExtensions.ToNative(fontImageSource.Color);
}
btn.Icon = icon;
diff --git a/src/Compatibility/Core/src/WinUI/Shell/ShellRenderer.cs b/src/Compatibility/Core/src/WinUI/Shell/ShellRenderer.cs
index ef0340b92859..a0e1833a7d05 100644
--- a/src/Compatibility/Core/src/WinUI/Shell/ShellRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shell/ShellRenderer.cs
@@ -11,6 +11,7 @@
using Microsoft.UI;
using System.Collections.Specialized;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -302,7 +303,7 @@ protected virtual void UpdateFlyoutBackgroundColor()
new WSolidColorBrush(uiColor);
}
else
- FlyoutBackgroundColor = _shell.FlyoutBackgroundColor.ToBrush();
+ FlyoutBackgroundColor = Maui.ColorExtensions.ToNative(_shell.FlyoutBackgroundColor);
}
protected virtual void OnElementSet(Shell shell)
diff --git a/src/Compatibility/Core/src/WinUI/Shell/ShellSplitView.cs b/src/Compatibility/Core/src/WinUI/Shell/ShellSplitView.cs
index 84fe596dd8d5..860a754bfec1 100644
--- a/src/Compatibility/Core/src/WinUI/Shell/ShellSplitView.cs
+++ b/src/Compatibility/Core/src/WinUI/Shell/ShellSplitView.cs
@@ -2,6 +2,7 @@
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using WRectangle = Microsoft.UI.Xaml.Shapes.Rectangle;
using Microsoft.UI.Xaml;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/Shell/ShellToolbarItemRenderer.cs b/src/Compatibility/Core/src/WinUI/Shell/ShellToolbarItemRenderer.cs
index 6faaa5f8213c..4258653d686e 100644
--- a/src/Compatibility/Core/src/WinUI/Shell/ShellToolbarItemRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/Shell/ShellToolbarItemRenderer.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Input;
@@ -44,14 +45,16 @@ void ToolbarItemChanged(ToolbarItem oldItem, ToolbarItem newItem)
if(oldItem != null)
oldItem.PropertyChanged -= ToolbarItemPropertyChanged;
- this.SetAutomationProperties(newItem, defaultName: newItem?.Text);
+ // TODO MAUI
+ this.SetAutomationProperties(newItem, null, defaultName: newItem?.Text);
if (newItem != null)
newItem.PropertyChanged += ToolbarItemPropertyChanged;
void ToolbarItemPropertyChanged(object sender, PropertyChangedEventArgs e)
{
- this.SetAutomationProperties(newItem, defaultName: newItem?.Text);
+ // TODO MAUI
+ this.SetAutomationProperties(newItem, null, defaultName: newItem?.Text);
}
}
}
diff --git a/src/Compatibility/Core/src/WinUI/SliderRenderer.cs b/src/Compatibility/Core/src/WinUI/SliderRenderer.cs
index 59c17d4f47ba..efd951f55ead 100644
--- a/src/Compatibility/Core/src/WinUI/SliderRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/SliderRenderer.cs
@@ -7,6 +7,7 @@
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Media.Imaging;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -109,7 +110,7 @@ void UpdateMinimumTrackColor()
if (Element.MinimumTrackColor.IsDefault())
Control.Foreground = defaultforegroundcolor;
else
- Control.Foreground = Element.MinimumTrackColor.ToBrush();
+ Control.Foreground = Maui.ColorExtensions.ToNative(Element.MinimumTrackColor);
}
}
@@ -120,7 +121,7 @@ void UpdateMaximumTrackColor()
if (Element.MaximumTrackColor.IsDefault())
Control.Background = defaultbackgroundcolor;
else
- Control.Background = Element.MaximumTrackColor.ToBrush();
+ Control.Background = Maui.ColorExtensions.ToNative(Element.MaximumTrackColor);
}
}
@@ -192,7 +193,7 @@ protected override void UpdateBackgroundColor()
Color backgroundColor = Element.BackgroundColor;
if (!backgroundColor.IsDefault())
{
- Control.Background = backgroundColor.ToBrush();
+ Control.Background = Maui.ColorExtensions.ToNative(backgroundColor);
}
else
{
diff --git a/src/Compatibility/Core/src/WinUI/StepperControl.cs b/src/Compatibility/Core/src/WinUI/StepperControl.cs
index 5f3bff00a9fc..a1e78f6c9ee2 100644
--- a/src/Compatibility/Core/src/WinUI/StepperControl.cs
+++ b/src/Compatibility/Core/src/WinUI/StepperControl.cs
@@ -9,6 +9,7 @@
using WVisualStateGroup = Microsoft.UI.Xaml.VisualStateGroup;
using WVisualState = Microsoft.UI.Xaml.VisualState;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -230,7 +231,7 @@ void UpdateButtonBackgroundColor(Color value)
return;
}
- WBrush brush = value.ToBrush();
+ WBrush brush = Maui.ColorExtensions.ToNative(value);
_minus = GetTemplateChild("Minus") as Microsoft.UI.Xaml.Controls.Button;
_plus = GetTemplateChild("Plus") as Microsoft.UI.Xaml.Controls.Button;
if (_minus != null)
diff --git a/src/Compatibility/Core/src/WinUI/StepperRenderer.cs b/src/Compatibility/Core/src/WinUI/StepperRenderer.cs
index cc4536ad4811..83be6543164c 100644
--- a/src/Compatibility/Core/src/WinUI/StepperRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/StepperRenderer.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/StreamImagesourceHandler.cs b/src/Compatibility/Core/src/WinUI/StreamImagesourceHandler.cs
index f5bd2dc9c311..3d92a21ddfa4 100644
--- a/src/Compatibility/Core/src/WinUI/StreamImagesourceHandler.cs
+++ b/src/Compatibility/Core/src/WinUI/StreamImagesourceHandler.cs
@@ -2,6 +2,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Maui.Controls.Platform;
using Microsoft.UI.Xaml.Media.Imaging;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
diff --git a/src/Compatibility/Core/src/WinUI/SwipeViewRenderer.cs b/src/Compatibility/Core/src/WinUI/SwipeViewRenderer.cs
index f60fdb2bd6a3..ab836d21a30e 100644
--- a/src/Compatibility/Core/src/WinUI/SwipeViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/SwipeViewRenderer.cs
@@ -9,6 +9,7 @@
using WSwipeItem = Microsoft.UI.Xaml.Controls.SwipeItem;
using WSwipeMode = Microsoft.UI.Xaml.Controls.SwipeMode;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -131,7 +132,7 @@ protected override void UpdateBackgroundColor()
if (Control != null)
{
- Control.Background = backgroundColor.IsDefault() ? null : backgroundColor.ToBrush();
+ Control.Background = backgroundColor.IsDefault() ? null : Maui.ColorExtensions.ToNative(backgroundColor);
}
base.UpdateBackgroundColor();
@@ -256,10 +257,10 @@ void UpdateSwipeItem(SwipeItem formsSwipeItem)
{
windowsSwipeItem.Text = formsSwipeItem.Text;
windowsSwipeItem.IconSource = formsSwipeItem.IconImageSource.ToWindowsIconSource();
- windowsSwipeItem.Background = formsSwipeItem.BackgroundColor.ToBrush();
+ windowsSwipeItem.Background = Maui.ColorExtensions.ToNative(formsSwipeItem.BackgroundColor);
var textColor = GetSwipeItemColor(formsSwipeItem.BackgroundColor);
- windowsSwipeItem.Foreground = textColor.ToBrush();
+ windowsSwipeItem.Foreground = Maui.ColorExtensions.ToNative(textColor);
}
}
@@ -326,8 +327,8 @@ WSwipeItems CreateSwipeItems(SwipeDirection swipeDirection)
var windowsSwipeItem = new WSwipeItem
{
- Background = formsSwipeItem.BackgroundColor.IsDefault() ? null : formsSwipeItem.BackgroundColor.ToBrush(),
- Foreground = textColor.ToBrush(),
+ Background = formsSwipeItem.BackgroundColor.IsDefault() ? null : Maui.ColorExtensions.ToNative(formsSwipeItem.BackgroundColor),
+ Foreground = Maui.ColorExtensions.ToNative(textColor),
IconSource = formsSwipeItem.IconImageSource.ToWindowsIconSource(),
Text = !string.IsNullOrEmpty(formsSwipeItem.Text) ? formsSwipeItem.Text : string.Empty,
BehaviorOnInvoked = GetSwipeBehaviorOnInvoked(items.SwipeBehaviorOnInvoked)
diff --git a/src/Compatibility/Core/src/WinUI/SwitchRenderer.cs b/src/Compatibility/Core/src/WinUI/SwitchRenderer.cs
index 4b9e70ffd3b2..7384c740d52e 100644
--- a/src/Compatibility/Core/src/WinUI/SwitchRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/SwitchRenderer.cs
@@ -11,6 +11,7 @@
using WRectangle = Microsoft.UI.Xaml.Shapes.Rectangle;
using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;
using WVisualStateManager = Microsoft.UI.Xaml.VisualStateManager;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -199,7 +200,7 @@ void UpdateThumbColor()
if (!Element.ThumbColor.IsDefault())
{
- var brush = Element.ThumbColor.ToBrush();
+ var brush = Maui.ColorExtensions.ToNative(Element.ThumbColor);
brush.Opacity = _originalThumbOnBrush.Opacity;
frame.Value = brush;
}
@@ -218,7 +219,7 @@ void UpdateThumbColor()
_originalThumbOnBrush = thumb.Fill;
if (!Element.ThumbColor.IsDefault())
- thumb.Fill = Element.ThumbColor.ToBrush();
+ thumb.Fill = Maui.ColorExtensions.ToNative(Element.ThumbColor);
else
thumb.Fill = _originalThumbOnBrush;
}
diff --git a/src/Compatibility/Core/src/WinUI/TableViewRenderer.cs b/src/Compatibility/Core/src/WinUI/TableViewRenderer.cs
index 7cc8d7fe2e7b..67c5f1a82ada 100644
--- a/src/Compatibility/Core/src/WinUI/TableViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/TableViewRenderer.cs
@@ -4,6 +4,7 @@
using Microsoft.UI.Xaml.Data;
using WItemsControl = Microsoft.UI.Xaml.Controls.ItemsControl;
using WSelectionChangedEventArgs = Microsoft.UI.Xaml.Controls.SelectionChangedEventArgs;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/TextBlockExtensions.cs b/src/Compatibility/Core/src/WinUI/TextBlockExtensions.cs
index 557818e9bf97..27f0bd0530f2 100644
--- a/src/Compatibility/Core/src/WinUI/TextBlockExtensions.cs
+++ b/src/Compatibility/Core/src/WinUI/TextBlockExtensions.cs
@@ -2,7 +2,7 @@
using System.Linq;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
-#if WINDOWS_UWP
+#if WINDOWS
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Documents;
using NativeSize = Windows.Foundation.Size;
@@ -12,7 +12,7 @@
using NativeSize = System.Windows.Size;
#endif
-#if WINDOWS_UWP
+#if WINDOWS
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
#else
namespace Microsoft.Maui.Controls.Compatibility.Platform.WPF
diff --git a/src/Compatibility/Core/src/WinUI/TimePickerRenderer.cs b/src/Compatibility/Core/src/WinUI/TimePickerRenderer.cs
index ad09733763d5..981b1663a00b 100644
--- a/src/Compatibility/Core/src/WinUI/TimePickerRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/TimePickerRenderer.cs
@@ -8,6 +8,7 @@
using Microsoft.UI.Xaml.Controls.Primitives;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -183,7 +184,7 @@ void UpdateCharacterSpacing()
void UpdateTextColor()
{
Color color = Element.TextColor;
- Control.Foreground = color.IsDefault() ? (_defaultBrush ?? color.ToBrush()) : color.ToBrush();
+ Control.Foreground = color.IsDefault() ? (_defaultBrush ?? Maui.ColorExtensions.ToNative(color)) : Maui.ColorExtensions.ToNative(color);
}
}
}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/WinUI/UriImageSourceHandler.cs b/src/Compatibility/Core/src/WinUI/UriImageSourceHandler.cs
index 3c79a5d69f6e..3bf5a21e9046 100644
--- a/src/Compatibility/Core/src/WinUI/UriImageSourceHandler.cs
+++ b/src/Compatibility/Core/src/WinUI/UriImageSourceHandler.cs
@@ -6,6 +6,7 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.Maui.Controls.Internals;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/ViewRenderer.cs b/src/Compatibility/Core/src/WinUI/ViewRenderer.cs
index 7ee9e0934335..b6d0570ca664 100644
--- a/src/Compatibility/Core/src/WinUI/ViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/ViewRenderer.cs
@@ -1,5 +1,6 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation.Peers;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/VisualElementRenderer.cs b/src/Compatibility/Core/src/WinUI/VisualElementRenderer.cs
index eef5b8576ece..8139e4be3e6d 100644
--- a/src/Compatibility/Core/src/WinUI/VisualElementRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/VisualElementRenderer.cs
@@ -11,6 +11,7 @@
using WRect = Windows.Foundation.Rect;
using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;
using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
@@ -434,7 +435,8 @@ protected virtual void SetAutomationPropertiesLabeledBy()
if (Control == null)
return;
- _defaultAutomationPropertiesLabeledBy = Control.SetAutomationPropertiesLabeledBy(Element, _defaultAutomationPropertiesLabeledBy);
+ // TODO MAUI
+ _defaultAutomationPropertiesLabeledBy = Control.SetAutomationPropertiesLabeledBy(Element, null, _defaultAutomationPropertiesLabeledBy);
}
protected void SetNativeControl(TNativeElement control)
@@ -499,7 +501,7 @@ protected virtual void UpdateBackgroundColor()
{
if (!backgroundColor.IsDefault())
{
- _control.Background = backgroundColor.ToBrush();
+ _control.Background = Maui.ColorExtensions.ToNative(backgroundColor);
}
else
{
@@ -511,7 +513,7 @@ protected virtual void UpdateBackgroundColor()
{
if (!backgroundColor.IsDefault())
{
- backgroundLayer.Background = backgroundColor.ToBrush();
+ backgroundLayer.Background = Maui.ColorExtensions.ToNative(backgroundColor);
}
else
{
@@ -539,7 +541,7 @@ protected virtual void UpdateBackground()
else
{
if (!backgroundColor.IsDefault())
- _control.Background = backgroundColor.ToBrush();
+ _control.Background = Maui.ColorExtensions.ToNative(backgroundColor);
else
{
_control.ClearValue(Microsoft.UI.Xaml.Controls.Control.BackgroundProperty);
@@ -554,7 +556,7 @@ protected virtual void UpdateBackground()
else
{
if (!backgroundColor.IsDefault())
- backgroundLayer.Background = backgroundColor.ToBrush();
+ backgroundLayer.Background = Maui.ColorExtensions.ToNative(backgroundColor);
else
backgroundLayer.ClearValue(BackgroundProperty);
}
diff --git a/src/Compatibility/Core/src/WinUI/VisualElementTracker.cs b/src/Compatibility/Core/src/WinUI/VisualElementTracker.cs
index 636124dbbc55..ea1c54e9b847 100644
--- a/src/Compatibility/Core/src/WinUI/VisualElementTracker.cs
+++ b/src/Compatibility/Core/src/WinUI/VisualElementTracker.cs
@@ -202,7 +202,7 @@ void HandleDragStarting(UIElement sender, Microsoft.UI.Xaml.DragStartingEventArg
}
var renderer = sender as IVisualElementRenderer;
- var args = rec.SendDragStarting(renderer?.Element);
+ var args = rec.SendDragStarting(renderer?.Element as IView);
e.Data.Properties["_XFPropertes_DONTUSE"] = args.Data;
if (!args.Handled && renderer != null)
diff --git a/src/Compatibility/Core/src/WinUI/WebViewRenderer.cs b/src/Compatibility/Core/src/WinUI/WebViewRenderer.cs
index 0d06deda3d45..1a743cf314f4 100644
--- a/src/Compatibility/Core/src/WinUI/WebViewRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/WebViewRenderer.cs
@@ -12,9 +12,7 @@
using System.Linq;
using Microsoft.UI.Xaml.Controls;
using WWebView = Microsoft.UI.Xaml.Controls.WebView2;
-
-//TODO WINUI3
-//using WWebViewExecutionMode = Microsoft.UI.Xaml.Controls.WebViewExecutionMode;
+using Microsoft.Maui.Controls.Platform;
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
diff --git a/src/Compatibility/Core/src/WinUI/Extensions/WinUIHelpers.cs b/src/Compatibility/Core/src/WinUI/WinUIHelpers.cs
similarity index 91%
rename from src/Compatibility/Core/src/WinUI/Extensions/WinUIHelpers.cs
rename to src/Compatibility/Core/src/WinUI/WinUIHelpers.cs
index d63feb5fe6d1..0b7942dc87de 100644
--- a/src/Compatibility/Core/src/WinUI/Extensions/WinUIHelpers.cs
+++ b/src/Compatibility/Core/src/WinUI/WinUIHelpers.cs
@@ -10,7 +10,7 @@
namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
- public static class WinUIHelpers
+ static class WinUIHelpers
{
public static WThickness CreateThickness(double left, double top, double right, double bottom)
{
@@ -55,7 +55,7 @@ public static WCornerRadius CreateCornerRadius(double all)
};
}
- internal static WGridLength CreateGridLength(int v, UwpGridUnitType auto)
+ public static WGridLength CreateGridLength(int v, UwpGridUnitType auto)
{
return new WGridLength(v, auto);
}
diff --git a/src/Compatibility/Core/src/WinUI/WindowsBasePlatformServices.cs b/src/Compatibility/Core/src/WinUI/WindowsBasePlatformServices.cs
index 2974223ccacd..caeb71fa10fd 100644
--- a/src/Compatibility/Core/src/WinUI/WindowsBasePlatformServices.cs
+++ b/src/Compatibility/Core/src/WinUI/WindowsBasePlatformServices.cs
@@ -141,7 +141,7 @@ public Color GetNamedColor(string name)
if (!Microsoft.UI.Xaml.Application.Current?.Resources.ContainsKey(name) ?? true)
return KnownColor.Default;
- return ((Windows.UI.Color)Microsoft.UI.Xaml.Application.Current?.Resources[name]).ToFormsColor();
+ return ((Windows.UI.Color)Microsoft.UI.Xaml.Application.Current?.Resources[name]).ToColor();
}
public async Task GetStreamAsync(Uri uri, CancellationToken cancellationToken)
diff --git a/src/Compatibility/Core/src/iOS/RendererToHandlerShim.cs b/src/Compatibility/Core/src/iOS/RendererToHandlerShim.cs
index 886899c0c6f2..714072ceb2be 100644
--- a/src/Compatibility/Core/src/iOS/RendererToHandlerShim.cs
+++ b/src/Compatibility/Core/src/iOS/RendererToHandlerShim.cs
@@ -2,7 +2,6 @@
using ViewHandler = Microsoft.Maui.Handlers.ViewHandler;
using UIKit;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
-using Microsoft.Maui.Handlers;
namespace Microsoft.Maui.Controls.Compatibility
{
@@ -21,7 +20,7 @@ public static IViewHandler CreateShim(object renderer)
return new RendererToHandlerShim();
}
- public RendererToHandlerShim() : base(Handlers.ViewHandler.ViewMapper)
+ public RendererToHandlerShim() : base(ViewHandler.ViewMapper)
{
}
diff --git a/src/Compatibility/Core/tests/WinUI/Compatibility.Windows.UnitTests.csproj b/src/Compatibility/Core/tests/WinUI/Compatibility.Windows.UnitTests.csproj
index 7e154921d89c..ebe7596c7dbe 100644
--- a/src/Compatibility/Core/tests/WinUI/Compatibility.Windows.UnitTests.csproj
+++ b/src/Compatibility/Core/tests/WinUI/Compatibility.Windows.UnitTests.csproj
@@ -4,7 +4,7 @@
10.0.17134.0
Microsoft.Maui.Controls.Compatibility.UAP.UnitTests
win10-x86;win10-x64;win10-arm64
- $(DefineConstants);DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP;UWP_16299
+ $(DefineConstants);DEBUG;TRACE;NETFX_CORE;WINDOWS;UWP_16299
1701;1702;CS8305;8305;CA1416
@@ -62,7 +62,7 @@
full
false
bin\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
prompt
4
@@ -71,7 +71,7 @@
pdbonly
true
bin\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
prompt
4
@@ -79,7 +79,7 @@
x86
true
bin\x86\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
false
@@ -88,7 +88,7 @@
x86
bin\x86\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
@@ -99,7 +99,7 @@
ARM
true
bin\ARM\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
false
@@ -108,7 +108,7 @@
ARM
bin\ARM\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
@@ -119,7 +119,7 @@
ARM64
true
bin\ARM64\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
false
@@ -128,7 +128,7 @@
ARM64
bin\ARM64\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
@@ -139,7 +139,7 @@
x64
true
bin\x64\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
false
@@ -148,7 +148,7 @@
x64
bin\x64\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
diff --git a/src/Compatibility/Maps/src/UWP/Compatibility.Maps.UWP.csproj b/src/Compatibility/Maps/src/UWP/Compatibility.Maps.UWP.csproj
index e2437ce16ec6..d0200a24760e 100644
--- a/src/Compatibility/Maps/src/UWP/Compatibility.Maps.UWP.csproj
+++ b/src/Compatibility/Maps/src/UWP/Compatibility.Maps.UWP.csproj
@@ -8,12 +8,12 @@
false
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
true
bin\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
diff --git a/src/Controls/DualScreen/sample/DualScreen.UWP/DualScreen.UWP.csproj b/src/Controls/DualScreen/sample/DualScreen.UWP/DualScreen.UWP.csproj
index bc44d1067c54..9f1516b5fdd6 100644
--- a/src/Controls/DualScreen/sample/DualScreen.UWP/DualScreen.UWP.csproj
+++ b/src/Controls/DualScreen/sample/DualScreen.UWP/DualScreen.UWP.csproj
@@ -22,7 +22,7 @@
true
bin\ARM\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
ARM
@@ -32,7 +32,7 @@
bin\ARM\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
@@ -45,7 +45,7 @@
true
bin\x64\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
x64
@@ -55,7 +55,7 @@
bin\x64\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
@@ -68,7 +68,7 @@
true
bin\x86\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ DEBUG;TRACE;NETFX_CORE;WINDOWS
;2008
full
x86
@@ -78,7 +78,7 @@
bin\x86\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
+ TRACE;NETFX_CORE;WINDOWS
true
;2008
pdbonly
diff --git a/src/Controls/samples/Controls.Sample/Maui.Controls.Sample-net6.csproj b/src/Controls/samples/Controls.Sample/Maui.Controls.Sample-net6.csproj
index 98d6be1d4af4..ba140880f3ca 100644
--- a/src/Controls/samples/Controls.Sample/Maui.Controls.Sample-net6.csproj
+++ b/src/Controls/samples/Controls.Sample/Maui.Controls.Sample-net6.csproj
@@ -11,7 +11,7 @@
$(NoWarn);CA1416;CS8305
- $(DefineConstants);WINDOWS_UWP;WINDOWS
+ $(DefineConstants);WINDOWS
diff --git a/src/Controls/samples/Controls.Sample/Pages/MainPage.cs b/src/Controls/samples/Controls.Sample/Pages/MainPage.cs
index 274fa12cf537..dc85875df5a3 100644
--- a/src/Controls/samples/Controls.Sample/Pages/MainPage.cs
+++ b/src/Controls/samples/Controls.Sample/Pages/MainPage.cs
@@ -20,6 +20,12 @@ public class MainPage : BasePage
public MainPage(IServiceProvider services, MainPageViewModel viewModel)
{
+ ToolbarItems.Add(new ToolbarItem()
+ {
+ Text = "Page"
+ });
+
+ Title = "Welcome to the Samples";
_services = services;
BindingContext = _viewModel = viewModel;
@@ -58,6 +64,15 @@ void SetupMauiLayout()
verticalStack.Add(new Label { Text = "This should be BOLD text!", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center });
verticalStack.Add(new Label { Text = "This should have character spacing!", CharacterSpacing = 3 });
verticalStack.Add(new Label { Text = "This should be a CUSTOM font!", FontFamily = "Dokdo" });
+ verticalStack.Add(
+ new Button {
+ Text = "Push a Page",
+ Command = new Command(async () =>
+ {
+ await Navigation.PushAsync(new SemanticsPage());
+ })
+ }
+ );
#if __ANDROID__
diff --git a/src/Controls/samples/Controls.Sample/Pages/NavPage.cs b/src/Controls/samples/Controls.Sample/Pages/NavPage.cs
new file mode 100644
index 000000000000..baa61ee0e462
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample/Pages/NavPage.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Maui.Controls.Sample.ViewModel;
+using Microsoft.Maui.Controls;
+
+namespace Maui.Controls.Sample.Pages
+{
+ public class NavPage : NavigationPage
+ {
+ public NavPage(IServiceProvider services, MainPageViewModel viewModel) :
+ base(new MainPage(services, viewModel))
+ {
+ ToolbarItems.Add(new ToolbarItem()
+ {
+ Text = "Nav Page"
+ });
+
+ }
+ }
+}
diff --git a/src/Controls/samples/Controls.Sample/Startup.cs b/src/Controls/samples/Controls.Sample/Startup.cs
index 02d416dacea1..97af005435dc 100644
--- a/src/Controls/samples/Controls.Sample/Startup.cs
+++ b/src/Controls/samples/Controls.Sample/Startup.cs
@@ -12,6 +12,7 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Maui;
using Microsoft.Maui.Controls.Compatibility;
+using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Essentials;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.LifecycleEvents;
@@ -20,8 +21,8 @@ namespace Maui.Controls.Sample
{
public class Startup : IStartup
{
- enum PageType { Xaml, Semantics, Main, Blazor }
- private PageType _pageType = PageType.Main;
+ enum PageType { Xaml, Semantics, Main, Blazor, NavigationPage }
+ private PageType _pageType = PageType.NavigationPage;
public readonly static bool UseXamlApp = true;
@@ -45,6 +46,7 @@ public void Configure(IAppHostBuilder appBuilder)
appBuilder.EnableHotReload();
#endif
appBuilder
+ .UseMauiControlsHandlers()
#if NET6_0_OR_GREATER
.RegisterBlazorMauiWebView()
#endif
@@ -69,6 +71,7 @@ public void Configure(IAppHostBuilder appBuilder)
serviceType: typeof(IPage),
implementationType: _pageType switch
{
+ PageType.NavigationPage => typeof(NavPage),
PageType.Xaml => typeof(XamlPage),
PageType.Semantics => typeof(SemanticsPage),
PageType.Blazor =>
diff --git a/src/Controls/src/Core/AppHostBuilderExtensions.cs b/src/Controls/src/Core/AppHostBuilderExtensions.cs
new file mode 100644
index 000000000000..85b3069435cb
--- /dev/null
+++ b/src/Controls/src/Core/AppHostBuilderExtensions.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Maui.Controls.Handlers;
+using Microsoft.Maui.Hosting;
+
+namespace Microsoft.Maui.Controls.Hosting
+{
+ public static class AppHostBuilderExtensions
+ {
+ static readonly Dictionary DefaultMauiControlHandlers = new Dictionary
+ {
+ { typeof(NavigationPage), typeof(NavigationPageHandler) },
+ };
+
+ public static IAppHostBuilder UseMauiControlsHandlers(this IAppHostBuilder builder)
+ {
+ return builder
+ .ConfigureMauiHandlers((_, handlersCollection) => handlersCollection.AddHandlers(DefaultMauiControlHandlers))
+ .ConfigureServices(ConfigureNativeServices);
+ }
+
+ private static void ConfigureNativeServices(HostBuilderContext arg1, IServiceCollection arg2)
+ {
+#if WINDOWS
+ if (!UI.Xaml.Application.Current.Resources.ContainsKey("MauiControlsPageControlStyle"))
+ {
+ var myResourceDictionary = new Microsoft.UI.Xaml.ResourceDictionary();
+ myResourceDictionary.Source = new Uri("ms-appx:///Microsoft.Maui.Controls/Maui/Platform/Windows/Styles/Resources.xbf");
+ Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
+ }
+#endif
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Application.cs b/src/Controls/src/Core/Application.cs
index 47d4a606e34f..6a1372ea2a5d 100644
--- a/src/Controls/src/Core/Application.cs
+++ b/src/Controls/src/Core/Application.cs
@@ -321,13 +321,17 @@ protected virtual void OnStart()
{
}
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void ClearCurrent() => Current = null;
+ internal static void ClearCurrent() => Current = null;
[EditorBrowsable(EditorBrowsableState.Never)]
public static bool IsApplicationOrNull(Element element)
{
- return element == null || element is Application;
+ return element == null || element is Application || element is IWindow;
+ }
+
+ internal static bool IsApplicationOrNull(IView element)
+ {
+ return element == null || element is Application || element is IWindow;
}
internal override void OnParentResourcesChanged(IEnumerable> values)
diff --git a/src/Controls/src/Core/ColorExtensions.Windows.cs b/src/Controls/src/Core/ColorExtensions.Windows.cs
new file mode 100644
index 000000000000..236067522af8
--- /dev/null
+++ b/src/Controls/src/Core/ColorExtensions.Windows.cs
@@ -0,0 +1,28 @@
+using System;
+using Windows.UI;
+using Microsoft.UI;
+using Microsoft.Maui.Graphics;
+using WBrush = Microsoft.UI.Xaml.Media.Brush;
+using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ public static partial class ColorExtensions
+ {
+ [Obsolete("ToBrush is obsolete. Please use ToNative instead")]
+ public static WBrush ToBrush(this Graphics.Color color) => color.ToNative();
+
+
+ [Obsolete("ToFormsColor is obsolete. Please use ToColor instead")]
+ public static Graphics.Color ToFormsColor(this Windows.UI.Color color)
+ {
+ return color.ToColor();
+ }
+
+ [Obsolete("ToFormsColor is obsolete. Please use ToColor instead")]
+ public static Graphics.Color ToFormsColor(this WSolidColorBrush solidColorBrush)
+ {
+ return solidColorBrush.Color.ToColor();
+ }
+ }
+}
diff --git a/src/Controls/src/Core/ColorExtensions.cs b/src/Controls/src/Core/ColorExtensions.cs
index dc37ac04143c..3cca6fc50372 100644
--- a/src/Controls/src/Core/ColorExtensions.cs
+++ b/src/Controls/src/Core/ColorExtensions.cs
@@ -2,7 +2,7 @@
namespace Microsoft.Maui.Controls
{
- public static class ColorExtensions
+ public static partial class ColorExtensions
{
public static bool IsDefault(this Graphics.Color color)
{
@@ -14,16 +14,5 @@ public static bool IsNotDefault(this Graphics.Color color)
return !IsDefault(color);
}
}
-
- public static class KnownColor
- {
- public static Color Default => null;
-
- public static Color Transparent { get; } = new(255, 255, 255, 0);
-
- public static void SetAccent(Color value) => Accent = value;
-
- public static Color Accent { get; internal set; }
- }
}
diff --git a/src/Controls/src/Core/Controls.Core-net6.csproj b/src/Controls/src/Core/Controls.Core-net6.csproj
index ec5841e72792..d7927fe6be94 100644
--- a/src/Controls/src/Core/Controls.Core-net6.csproj
+++ b/src/Controls/src/Core/Controls.Core-net6.csproj
@@ -8,14 +8,12 @@
Microsoft.Maui.Controls
+
-
-
-
diff --git a/src/Controls/src/Core/Controls.Core.csproj b/src/Controls/src/Core/Controls.Core.csproj
index 00b146aafa64..92769bbfb7b3 100644
--- a/src/Controls/src/Core/Controls.Core.csproj
+++ b/src/Controls/src/Core/Controls.Core.csproj
@@ -6,6 +6,7 @@
Microsoft.Maui.Controls
+
diff --git a/src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs b/src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs
index cf96e22d0fb2..11ac65ddaff0 100644
--- a/src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs
+++ b/src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs
@@ -79,7 +79,7 @@ public void SendDropCompleted(DropCompletedEventArgs args)
}
[EditorBrowsable(EditorBrowsableState.Never)]
- public DragStartingEventArgs SendDragStarting(VisualElement element)
+ public DragStartingEventArgs SendDragStarting(IView element)
{
var args = new DragStartingEventArgs();
diff --git a/src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs b/src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs
index 9b03fd2abc05..121f60fcf35a 100644
--- a/src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs
+++ b/src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs
@@ -99,13 +99,13 @@ public async Task SendDrop(DropEventArgs args)
{
var dataView = args.Data;
var internalProperties = dataView.PropertiesInternal;
- VisualElement dragSource = null;
+ IView dragSource = null;
ImageSource sourceTarget = await dataView.GetImageAsync();
string text = await dataView.GetTextAsync();
if (internalProperties.ContainsKey("DragSource"))
{
- dragSource = (VisualElement)internalProperties["DragSource"];
+ dragSource = (IView)internalProperties["DragSource"];
if (sourceTarget == null && dragSource is IImageElement imageElement)
sourceTarget = imageElement.Source;
diff --git a/src/Controls/src/Core/HandlerImpl/ContentPage.Impl.cs b/src/Controls/src/Core/HandlerImpl/ContentPage.Impl.cs
index c1e874f3e891..70f5b897d1a2 100644
--- a/src/Controls/src/Core/HandlerImpl/ContentPage.Impl.cs
+++ b/src/Controls/src/Core/HandlerImpl/ContentPage.Impl.cs
@@ -10,9 +10,6 @@ public partial class ContentPage : IPage, HotReload.IHotReloadableView
// TODO ezhart That there's a layout alignment here tells us this hierarchy needs work :)
public Primitives.LayoutAlignment HorizontalLayoutAlignment => Primitives.LayoutAlignment.Fill;
- // TODO ezhart super sus
- public Thickness Margin => Thickness.Zero;
-
IView IPage.Content => Content;
diff --git a/src/Controls/src/Core/HandlerImpl/NavigationPage.Impl.cs b/src/Controls/src/Core/HandlerImpl/NavigationPage.Impl.cs
new file mode 100644
index 000000000000..d0b6739f12ac
--- /dev/null
+++ b/src/Controls/src/Core/HandlerImpl/NavigationPage.Impl.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.Maui.Controls.Internals;
+using Microsoft.Maui.Graphics;
+
+namespace Microsoft.Maui.Controls
+{
+ public partial class NavigationPage : IView
+ {
+ Thickness IView.Margin => Thickness.Zero;
+
+ protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
+ {
+ if (Content is IFrameworkElement frameworkElement)
+ {
+ frameworkElement.Measure(widthConstraint, heightConstraint);
+ }
+
+ return new Size(widthConstraint, heightConstraint);
+ }
+
+ protected override Size ArrangeOverride(Rectangle bounds)
+ {
+ // Update the Bounds (Frame) for this page
+ Layout(bounds);
+
+ if (Content is IFrameworkElement element)
+ {
+ element.Arrange(bounds);
+ element.Handler?.SetFrame(element.Frame);
+ }
+
+ return Frame.Size;
+ }
+
+ IFrameworkElement Content =>
+ this.CurrentPage;
+ }
+
+}
diff --git a/src/Controls/src/Core/HandlerImpl/Page.Impl.cs b/src/Controls/src/Core/HandlerImpl/Page.Impl.cs
index dc763c856793..0f1483000e6c 100644
--- a/src/Controls/src/Core/HandlerImpl/Page.Impl.cs
+++ b/src/Controls/src/Core/HandlerImpl/Page.Impl.cs
@@ -1,13 +1,13 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using Microsoft.Maui.Controls.Internals;
+using Microsoft.Maui.Graphics;
namespace Microsoft.Maui.Controls
{
public partial class Page : IPage
{
- IView IPage.Content => throw new NotImplementedException();
+ IView IPage.Content => null;
- Thickness IView.Margin => Thickness.Zero;
+ // TODO ezhart super sus
+ public Thickness Margin => Thickness.Zero;
}
}
diff --git a/src/Controls/src/Core/HandlerImpl/RadioButton.Impl.cs b/src/Controls/src/Core/HandlerImpl/RadioButton.Impl.cs
new file mode 100644
index 000000000000..b894ec203bb0
--- /dev/null
+++ b/src/Controls/src/Core/HandlerImpl/RadioButton.Impl.cs
@@ -0,0 +1,6 @@
+namespace Microsoft.Maui.Controls
+{
+ public partial class RadioButton : IRadioButton
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.Standard.cs b/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.Standard.cs
new file mode 100644
index 000000000000..cb334e16e5c5
--- /dev/null
+++ b/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.Standard.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.Maui.Handlers;
+
+namespace Microsoft.Maui.Controls.Handlers
+{
+ public partial class NavigationPageHandler :
+ ViewHandler
+ {
+ public NavigationPageHandler() : base(ViewHandler.ViewMapper)
+ {
+
+ }
+
+ protected override object CreateNativeView()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.Windows.cs b/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.Windows.cs
new file mode 100644
index 000000000000..374d6b7bfc41
--- /dev/null
+++ b/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.Windows.cs
@@ -0,0 +1,723 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Threading.Tasks;
+using Windows.Devices.Input;
+using Windows.UI.Input;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media.Animation;
+using Windows.UI.Core;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.Maui.Controls.Internals;
+using static Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific.Page;
+using WBrush = Microsoft.UI.Xaml.Media.Brush;
+using WImageSource = Microsoft.UI.Xaml.Media.ImageSource;
+using Microsoft.Maui.Graphics;
+using Microsoft.Maui.Handlers;
+using Microsoft.Maui.Controls.Platform;
+
+namespace Microsoft.Maui.Controls.Handlers
+{
+ public partial class NavigationPageHandler :
+ ViewHandler, ITitleProvider, ITitleIconProvider,
+ ITitleViewProvider, IToolbarProvider, IToolBarForegroundBinder, IViewHandler
+ {
+ // Shane will move this once he starts working on other platforms :-)
+ public static PropertyMapper NavigationPageMapper
+ = new PropertyMapper(ViewHandler.ViewMapper)
+ {
+ [NavigationPage.BarTextColorProperty.PropertyName] = MapTitleColor,
+ [NavigationPage.BarBackgroundColorProperty.PropertyName] = MapNavigationBarBackground,
+ [NavigationPage.BarBackgroundProperty.PropertyName] = MapNavigationBarBackground,
+ [nameof(IPadding.Padding)] = MapPadding,
+ [nameof(NavigationPage.TitleIconImageSourceProperty.PropertyName)] = MapTitleIcon,
+ [nameof(NavigationPage.TitleViewProperty.PropertyName)] = MapTitleView,
+
+#if WINDOWS
+ [nameof(ToolbarPlacementProperty.PropertyName)] = MapToolbarPlacement,
+ [nameof(ToolbarDynamicOverflowEnabledProperty.PropertyName)] = MapToolbarDynamicOverflowEnabled,
+#endif
+ };
+
+ public NavigationPageHandler() : base(NavigationPageMapper)
+ {
+ }
+
+ Page _currentPage;
+ Page _previousPage;
+
+ FlyoutPage _parentFlyoutPage;
+ TabbedPage _parentTabbedPage;
+ bool _showTitle = true;
+ VisualElementTracker _tracker;
+ EntranceThemeTransition _transition;
+ bool _parentsLookedUp = false;
+
+ public void BindForegroundColor(AppBar appBar)
+ {
+ SetAppBarForegroundBinding(appBar);
+ }
+
+ public void BindForegroundColor(AppBarButton button)
+ {
+ SetAppBarForegroundBinding(button);
+ }
+
+ protected VisualElementTracker Tracker
+ {
+ get { return _tracker; }
+ set
+ {
+ if (_tracker == value)
+ return;
+
+ if (_tracker != null)
+ _tracker.Dispose();
+
+ _tracker = value;
+ }
+ }
+
+ //public void Dispose()
+ //{
+ // Dispose(true);
+ //}
+
+ void SetAppBarForegroundBinding(FrameworkElement element)
+ {
+ element.SetBinding(Control.ForegroundProperty,
+ new Microsoft.UI.Xaml.Data.Binding { Path = new PropertyPath("TitleBrush"), Source = NativeView, RelativeSource = new RelativeSource { Mode = RelativeSourceMode.TemplatedParent } });
+ }
+
+ WBrush ITitleProvider.BarBackgroundBrush
+ {
+ set
+ {
+ NativeView.ToolbarBackground = value;
+ UpdateTitleOnParents();
+ }
+ }
+
+ WBrush ITitleProvider.BarForegroundBrush
+ {
+ set
+ {
+ NativeView.TitleBrush = value;
+ UpdateTitleOnParents();
+ }
+ }
+
+ bool ITitleProvider.ShowTitle
+ {
+ get { return _showTitle; }
+ set
+ {
+ if (_showTitle == value)
+ return;
+
+ _showTitle = value;
+ UpdateTitleVisible();
+ UpdateTitleOnParents();
+ }
+ }
+
+ public string Title
+ {
+ get { return _currentPage?.Title; }
+
+ set { /*Not implemented but required by interface*/ }
+ }
+
+ public WImageSource TitleIcon { get; set; }
+
+ public View TitleView
+ {
+ get
+ {
+ if (_currentPage == null)
+ return null;
+
+ return NavigationPage.GetTitleView(_currentPage) as View;
+ }
+ set { /*Not implemented but required by interface*/ }
+ }
+
+ Task IToolbarProvider.GetCommandBarAsync()
+ {
+ return ((IToolbarProvider)NativeView)?.GetCommandBarAsync();
+ }
+
+ public FrameworkElement ContainerElement
+ {
+ get { return NativeView; }
+ }
+
+ IView IViewHandler.VirtualView
+ {
+ get { return VirtualView; }
+ }
+
+ public event EventHandler ElementChanged;
+
+ public override Size GetDesiredSize(double widthConstraint, double heightConstraint)
+ {
+ var constraint = new Windows.Foundation.Size(widthConstraint, heightConstraint);
+ IViewHandler childRenderer = VirtualView.CurrentPage.Handler;
+ FrameworkElement child = childRenderer.NativeView as FrameworkElement;
+
+ double oldWidth = child.Width;
+ double oldHeight = child.Height;
+
+ child.Height = double.NaN;
+ child.Width = double.NaN;
+
+ child.Measure(constraint);
+ var result = new Size(Math.Ceiling(child.DesiredSize.Width), Math.Ceiling(child.DesiredSize.Height));
+
+ child.Width = oldWidth;
+ child.Height = oldHeight;
+
+ return result;
+ }
+
+ object IViewHandler.NativeView
+ {
+ get
+ {
+ return NativeView;
+ }
+ }
+
+ protected override PageControl CreateNativeView()
+ {
+ return new PageControl();
+ }
+
+ public override void SetVirtualView(IView view)
+ {
+ base.SetVirtualView(view);
+
+ if (view != null && !(view is NavigationPage))
+ throw new ArgumentException("VirtualView must be a Page", nameof(view));
+
+ if (view is NavigationPage np && np != null && np.CurrentPage is null)
+ throw new InvalidOperationException(
+ "NavigationPage must have a root Page before being used. Either call PushAsync with a valid Page, or pass a Page to the constructor before usage.");
+
+ }
+
+ protected override void ConnectHandler(PageControl nativeView)
+ {
+ base.ConnectHandler(nativeView);
+
+ NativeView.PointerPressed += OnPointerPressed;
+ NativeView.SizeChanged += OnNativeSizeChanged;
+ Tracker = new BackgroundTracker(Control.BackgroundProperty)
+ {
+ Element = VirtualView,
+ Container = NativeView
+ };
+
+ SetPage(VirtualView.CurrentPage, false, false);
+
+ NativeView.Loaded += OnLoaded;
+ NativeView.Unloaded += OnUnloaded;
+
+ NativeView.DataContext = VirtualView.CurrentPage;
+
+ // Move this somewhere else
+ LookupRelevantParents();
+
+ // Enforce consistency rules on toolbar (show toolbar if top-level page is Navigation Page)
+ NativeView.ShouldShowToolbar = _parentFlyoutPage == null && _parentTabbedPage == null;
+ if (_parentTabbedPage != null)
+ VirtualView.Appearing += OnElementAppearing;
+
+ VirtualView.PushRequested += OnPushRequested;
+ VirtualView.PopRequested += OnPopRequested;
+ VirtualView.PopToRootRequested += OnPopToRootRequested;
+ VirtualView.InternalChildren.CollectionChanged += OnChildrenChanged;
+
+ if (!string.IsNullOrEmpty(VirtualView.AutomationId))
+ NativeView.SetValue(Microsoft.UI.Xaml.Automation.AutomationProperties.AutomationIdProperty, VirtualView.AutomationId);
+
+ PushExistingNavigationStack();
+ }
+
+ protected override void DisconnectHandler(PageControl nativeView)
+ {
+ base.DisconnectHandler(nativeView);
+
+ if (VirtualView == null)
+ return;
+
+ VirtualView.PushRequested -= OnPushRequested;
+ VirtualView.PopRequested -= OnPopRequested;
+ VirtualView.PopToRootRequested -= OnPopToRootRequested;
+ VirtualView.InternalChildren.CollectionChanged -= OnChildrenChanged;
+ NativeView.PointerPressed -= OnPointerPressed;
+ NativeView.SizeChanged -= OnNativeSizeChanged;
+ NativeView.Loaded -= OnLoaded;
+ NativeView.Unloaded -= OnUnloaded;
+
+ // from Dispose
+ VirtualView?.SendDisappearing();
+
+ NativeView.PointerPressed -= OnPointerPressed;
+ NativeView.SizeChanged -= OnNativeSizeChanged;
+ NativeView.Loaded -= OnLoaded;
+ NativeView.Unloaded -= OnUnloaded;
+
+ if (_parentTabbedPage != null)
+ VirtualView.Appearing -= OnElementAppearing;
+
+ SetPage(null, false, true);
+ _previousPage = null;
+
+ if (_parentTabbedPage != null)
+ _parentTabbedPage.PropertyChanged -= MultiPagePropertyChanged;
+
+ if (_parentFlyoutPage != null)
+ _parentFlyoutPage.PropertyChanged -= MultiPagePropertyChanged;
+ }
+
+ protected virtual void OnElementChanged(VisualElementChangedEventArgs e)
+ {
+ EventHandler changed = ElementChanged;
+ if (changed != null)
+ changed(this, e);
+ }
+
+ WBrush GetBarBackgroundColorBrush()
+ {
+ object defaultColor = GetDefaultColor();
+
+ if (VirtualView.BarBackgroundColor.IsDefault() && defaultColor != null)
+ return (WBrush)defaultColor;
+ return Maui.ColorExtensions.ToNative(VirtualView.BarBackgroundColor);
+ }
+
+ static WBrush GetBarBackgroundBrush(NavigationPage navigationPage)
+ {
+ var barBackground = navigationPage.BarBackground;
+ object defaultColor = GetDefaultColor();
+
+ if (!Brush.IsNullOrEmpty(barBackground))
+ return barBackground.ToBrush();
+
+ if (defaultColor != null)
+ return (WBrush)defaultColor;
+
+ return null;
+ }
+
+ static WBrush GetBarForegroundBrush(NavigationPage navigationPage)
+ {
+ object defaultColor = Microsoft.UI.Xaml.Application.Current.Resources["ApplicationForegroundThemeBrush"];
+ if (navigationPage.BarTextColor.IsDefault())
+ return (WBrush)defaultColor;
+ return Maui.ColorExtensions.ToNative(navigationPage.BarTextColor);
+ }
+
+ bool GetIsNavBarPossible()
+ {
+ return _showTitle;
+ }
+
+ void LookupRelevantParents()
+ {
+ IEnumerable parentPages = VirtualView.GetParentPages();
+
+ if (_parentTabbedPage != null)
+ _parentTabbedPage.PropertyChanged -= MultiPagePropertyChanged;
+ if (_parentFlyoutPage != null)
+ _parentFlyoutPage.PropertyChanged -= MultiPagePropertyChanged;
+
+ foreach (Page parentPage in parentPages)
+ {
+ _parentTabbedPage = parentPage as TabbedPage;
+ _parentFlyoutPage = parentPage as FlyoutPage;
+ }
+
+ if (_parentTabbedPage != null)
+ _parentTabbedPage.PropertyChanged += MultiPagePropertyChanged;
+ if (_parentFlyoutPage != null)
+ _parentFlyoutPage.PropertyChanged += MultiPagePropertyChanged;
+
+ UpdateShowTitle();
+ UpdateTitleOnParents();
+ _parentsLookedUp = true;
+ }
+
+ void MultiPagePropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == "CurrentPage" || e.PropertyName == "Detail")
+ {
+ UpdateTitleOnParents();
+ UpdateTitleIcon();
+ UpdateTitleView();
+ }
+ }
+
+ void OnBackClicked(object sender, RoutedEventArgs e)
+ {
+ VirtualView?.SendBackButtonPressed();
+ }
+
+ void OnChildrenChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ UpdateBackButton();
+ }
+
+ // TODO MAUI: hmmmmmm can we make this not be property changed based?
+ void OnCurrentPagePropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == NavigationPage.HasBackButtonProperty.PropertyName)
+ UpdateBackButton();
+ else if (e.PropertyName == NavigationPage.BackButtonTitleProperty.PropertyName)
+ UpdateBackButtonTitle();
+ else if (e.PropertyName == NavigationPage.HasNavigationBarProperty.PropertyName)
+ UpdateTitleVisible();
+ else if (e.PropertyName == Page.TitleProperty.PropertyName)
+ UpdateTitleOnParents();
+ else if (e.PropertyName == NavigationPage.TitleIconImageSourceProperty.PropertyName)
+ UpdateTitleIcon();
+ else if (e.PropertyName == NavigationPage.TitleViewProperty.PropertyName)
+ UpdateTitleView();
+ }
+
+ void OnElementAppearing(object sender, EventArgs e)
+ {
+ UpdateTitleVisible();
+ UpdateBackButton();
+ }
+
+ void OnLoaded(object sender, RoutedEventArgs args)
+ {
+ if (VirtualView == null)
+ return;
+
+ VirtualView.SendAppearing();
+ UpdateBackButton();
+ UpdateTitleOnParents();
+
+ if (_parentFlyoutPage != null)
+ {
+ UpdateTitleView();
+ UpdateTitleIcon();
+ }
+ }
+
+ void OnNativeSizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ UpdateContainerArea();
+ }
+
+ void OnPointerPressed(object sender, PointerRoutedEventArgs e)
+ {
+ if (e.Handled)
+ return;
+
+ var point = e.GetCurrentPoint(NativeView);
+ if (point == null)
+ return;
+
+ if (point.PointerDeviceType != PointerDeviceType.Mouse)
+ return;
+
+ if (point.Properties.IsXButton1Pressed)
+ {
+ e.Handled = true;
+ OnBackClicked(NativeView, e);
+ }
+ }
+
+ protected virtual void OnPopRequested(object sender, NavigationRequestedEventArgs e)
+ {
+ var newCurrent = VirtualView.Peek(1);
+ SetPage(newCurrent, e.Animated, true);
+ }
+
+ protected virtual void OnPopToRootRequested(object sender, NavigationRequestedEventArgs e)
+ {
+ SetPage(e.Page, e.Animated, true);
+ }
+
+ protected virtual void OnPushRequested(object sender, NavigationRequestedEventArgs e)
+ {
+ SetPage(e.Page, e.Animated, false);
+ }
+
+ void OnUnloaded(object sender, RoutedEventArgs args)
+ {
+ VirtualView?.SendDisappearing();
+ }
+
+ void PushExistingNavigationStack()
+ {
+ foreach (var page in VirtualView.Pages)
+ {
+ SetPage(page, false, false);
+ }
+ }
+
+ void SetPage(Page page, bool isAnimated, bool isPopping)
+ {
+ if (_currentPage != null)
+ {
+ if (isPopping)
+ {
+ _currentPage.Cleanup();
+ NativeView.TitleView?.Cleanup();
+ }
+
+ NativeView.Content = null;
+ _currentPage.PropertyChanged -= OnCurrentPagePropertyChanged;
+ }
+
+ if (!isPopping)
+ _previousPage = _currentPage;
+
+ _currentPage = page;
+
+ if (page == null)
+ return;
+
+ UpdateBackButton();
+ UpdateBackButtonTitle();
+
+ page.PropertyChanged += OnCurrentPagePropertyChanged;
+
+ IViewHandler renderer = page.GetOrCreateHandler(this.MauiContext);
+
+ UpdateTitleVisible();
+ UpdateTitleOnParents();
+ UpdateTitleView();
+
+ SetupPageTransition(_transition, isAnimated, isPopping);
+
+ NativeView.Content = renderer.NativeView;
+ NativeView.DataContext = page;
+ }
+
+ protected virtual void SetupPageTransition(Transition transition, bool isAnimated, bool isPopping)
+ {
+ if (isAnimated && transition == null)
+ {
+ transition = new EntranceThemeTransition();
+ _transition = (EntranceThemeTransition)transition;
+ NativeView.ContentTransitions = new TransitionCollection();
+ }
+
+ if (!isAnimated && NativeView.ContentTransitions?.Count > 0)
+ {
+ NativeView.ContentTransitions.Clear();
+ }
+ else if (isAnimated && NativeView.ContentTransitions.Contains(transition) == false)
+ {
+ NativeView.ContentTransitions.Clear();
+ NativeView.ContentTransitions.Add(transition);
+ }
+ }
+
+ void UpdateBackButtonTitle()
+ {
+ string title = null;
+ if (_previousPage != null)
+ title = NavigationPage.GetBackButtonTitle(_previousPage);
+
+ NativeView.BackButtonTitle = title;
+ }
+
+ void UpdateContainerArea()
+ {
+ VirtualView.ContainerArea = new Rectangle(0, 0, NativeView.ContentWidth, NativeView.ContentHeight);
+ }
+
+ void UpdateTitleVisible()
+ {
+ UpdateTitleOnParents();
+
+ bool showing = NativeView.TitleVisibility == Visibility.Visible;
+ bool newValue = GetIsNavBarPossible() && NavigationPage.GetHasNavigationBar(_currentPage);
+ if (showing == newValue)
+ return;
+
+ NativeView.TitleVisibility = newValue ? Visibility.Visible : Visibility.Collapsed;
+
+ // Force ContentHeight/Width to update, doesn't work from inside PageControl for some reason
+ NativeView.UpdateLayout();
+ UpdateContainerArea();
+ }
+
+ void UpdateShowTitle()
+ {
+ ((ITitleProvider)this).ShowTitle = _parentTabbedPage == null && _parentFlyoutPage == null;
+ }
+
+ static object GetDefaultColor()
+ {
+ return Microsoft.UI.Xaml.Application.Current.Resources["SystemControlBackgroundChromeMediumLowBrush"];
+ }
+
+ void UpdateBackButton()
+ {
+ if (_currentPage == null)
+ {
+ return;
+ }
+
+ bool showBackButton = VirtualView.InternalChildren.Count > 1 && NavigationPage.GetHasBackButton(_currentPage);
+ if (NativeVersion.IsDesktop)
+ {
+ //TODO MAUI: this means it's running as a desktop app
+ }
+ else
+ {
+ var navManager = SystemNavigationManager.GetForCurrentView();
+ if(navManager != null)
+ navManager.AppViewBackButtonVisibility = showBackButton ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
+ }
+
+ NativeView.SetBackButtonTitle(VirtualView);
+ }
+
+ void UpdateTitleOnParents()
+ {
+ if (VirtualView == null || _currentPage == null)
+ return;
+
+ ITitleProvider render = null;
+ if (_parentTabbedPage != null)
+ {
+ render = _parentTabbedPage.Handler as ITitleProvider;
+ if (render != null)
+ render.ShowTitle = (_parentTabbedPage.CurrentPage == VirtualView) && NavigationPage.GetHasNavigationBar(_currentPage);
+ }
+
+ if (_parentFlyoutPage != null)
+ {
+ render = _parentFlyoutPage.Handler as ITitleProvider;
+ if (render != null)
+ render.ShowTitle = (_parentFlyoutPage.Detail == VirtualView) && NavigationPage.GetHasNavigationBar(_currentPage);
+ }
+
+ if (render != null && render.ShowTitle)
+ {
+ render.Title = _currentPage.Title;
+
+ if (!Brush.IsNullOrEmpty(VirtualView.BarBackground))
+ render.BarBackgroundBrush = GetBarBackgroundBrush(VirtualView);
+ else
+ render.BarBackgroundBrush = GetBarBackgroundColorBrush();
+
+ render.BarForegroundBrush = GetBarForegroundBrush(VirtualView);
+ }
+
+ if (_showTitle || (render != null && render.ShowTitle))
+ {
+ ToolbarManager.UpdateToolbarItems(VirtualView)
+ .FireAndForget((e)=> Log.Warning(nameof(NavigationPage), $"{e}"));
+ }
+ }
+
+ void UpdatePadding()
+ {
+ NativeView.TitleInset = VirtualView.Padding.Left;
+ }
+
+ void UpdateTitleColor()
+ {
+ (this as ITitleProvider).BarForegroundBrush = GetBarForegroundBrush(VirtualView);
+ }
+
+ void UpdateNavigationBarBackground()
+ {
+ (this as ITitleProvider).BarBackgroundBrush = GetBarBackgroundBrush(VirtualView);
+ }
+
+ void UpdateTitleIcon() =>
+ UpdateTitleIconAsync()
+ .FireAndForget(errorCallback: (e) => Log.Warning(nameof(TitleIcon), $"{e}"));
+
+ async Task UpdateTitleIconAsync()
+ {
+ var page = _currentPage;
+ if (page == null)
+ return;
+
+ ImageSource source = NavigationPage.GetTitleIconImageSource(page);
+
+ TitleIcon = await source.ToWindowsImageSourceAsync();
+
+ if (NativeView == null || _currentPage != page)
+ return;
+
+ NativeView.TitleIcon = TitleIcon;
+
+ if (_parentFlyoutPage != null && this is ITitleIconProvider parent)
+ parent.TitleIcon = TitleIcon;
+
+ NativeView.UpdateLayout();
+ UpdateContainerArea();
+ }
+
+ void UpdateTitleView()
+ {
+ // if the life cycle hasn't reached the point where _parentFlyoutPage gets wired up then
+ // don't update the title view
+ if (_currentPage == null || !_parentsLookedUp)
+ return;
+
+ // If the container TitleView gets initialized before the FP TitleView it causes the
+ // FP TitleView to not render correctly
+ if (_parentFlyoutPage != null)
+ {
+ if (this is ITitleViewProvider parent)
+ parent.TitleView = TitleView;
+ }
+ else if (_parentFlyoutPage == null)
+ NativeView.TitleView = TitleView;
+
+ }
+
+ void UpdateToolbarPlacement()
+ {
+ if (NativeView == null)
+ {
+ return;
+ }
+
+ NativeView.ToolbarPlacement = VirtualView.OnThisPlatform().GetToolbarPlacement();
+ }
+
+ void UpdateToolbarDynamicOverflowEnabled()
+ {
+ if (NativeView == null)
+ {
+ return;
+ }
+
+ NativeView.ToolbarDynamicOverflowEnabled = VirtualView.OnThisPlatform().GetToolbarDynamicOverflowEnabled();
+ }
+
+ public static void MapPadding(NavigationPageHandler handler, NavigationPage view) =>
+ handler.UpdatePadding();
+
+ public static void MapTitleColor(NavigationPageHandler handler, NavigationPage view) => handler.UpdateTitleColor();
+
+ public static void MapNavigationBarBackground(NavigationPageHandler handler, NavigationPage view) => handler.UpdateNavigationBarBackground();
+
+ // TODO MAUI: Task Based Mappers?
+ public static void MapTitleIcon(NavigationPageHandler handler, NavigationPage view) => handler.UpdateTitleIcon();
+
+ public static void MapTitleView(NavigationPageHandler handler, NavigationPage view) => handler.UpdateTitleView();
+
+ public static void MapToolbarPlacement(NavigationPageHandler handler, NavigationPage view) => handler.UpdateToolbarPlacement();
+
+ public static void MapToolbarDynamicOverflowEnabled(NavigationPageHandler handler, NavigationPage view) => handler.UpdateToolbarDynamicOverflowEnabled();
+ }
+}
diff --git a/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.cs b/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.cs
new file mode 100644
index 000000000000..22c5cf9c2713
--- /dev/null
+++ b/src/Controls/src/Core/Handlers/NavigationPage/NavigationPageHandler.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.Maui.Handlers;
+
+namespace Microsoft.Maui.Controls.Handlers
+{
+ public partial class NavigationPageHandler
+ {
+ }
+}
diff --git a/src/Controls/src/Core/KnownColor.cs b/src/Controls/src/Core/KnownColor.cs
new file mode 100644
index 000000000000..de6d8826581f
--- /dev/null
+++ b/src/Controls/src/Core/KnownColor.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.Maui.Graphics;
+
+namespace Microsoft.Maui.Controls
+{
+ public static class KnownColor
+ {
+ public static Color Default => null;
+
+ public static Color Transparent { get; } = new(255, 255, 255, 0);
+
+ public static void SetAccent(Color value) => Accent = value;
+
+ public static Color Accent { get; internal set; }
+ }
+}
diff --git a/src/Controls/src/Core/NavigationPage.cs b/src/Controls/src/Core/NavigationPage.cs
index 6d6d8eda2e9b..a2d18a69d69a 100644
--- a/src/Controls/src/Core/NavigationPage.cs
+++ b/src/Controls/src/Core/NavigationPage.cs
@@ -8,7 +8,7 @@
namespace Microsoft.Maui.Controls
{
- public class NavigationPage : Page, IPageContainer, IBarElement, INavigationPageController, IElementConfiguration
+ public partial class NavigationPage : Page, IPageContainer, IBarElement, INavigationPageController, IElementConfiguration
{
public static readonly BindableProperty BackButtonTitleProperty = BindableProperty.CreateAttached("BackButtonTitle", typeof(string), typeof(Page), null);
diff --git a/src/Controls/src/Core/Platform/Windows/BackgroundTracker.cs b/src/Controls/src/Core/Platform/Windows/BackgroundTracker.cs
new file mode 100644
index 000000000000..d5f9ca68e7ef
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/BackgroundTracker.cs
@@ -0,0 +1,81 @@
+using System;
+using System.ComponentModel;
+using Microsoft.Maui.Graphics;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Media.Imaging;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal sealed class BackgroundTracker : VisualElementTracker where T : FrameworkElement
+ {
+ readonly DependencyProperty _backgroundProperty;
+ bool _backgroundNeedsUpdate = true;
+
+ public BackgroundTracker(DependencyProperty backgroundProperty)
+ {
+ if (backgroundProperty == null)
+ throw new ArgumentNullException("backgroundProperty");
+
+ _backgroundProperty = backgroundProperty;
+ }
+
+ protected override void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.IsOneOf(VisualElement.BackgroundColorProperty, VisualElement.BackgroundProperty, Page.BackgroundImageSourceProperty))
+ {
+ UpdateBackground();
+ }
+
+ base.OnPropertyChanged(sender, e);
+ }
+
+ protected override void UpdateNativeControl()
+ {
+ base.UpdateNativeControl();
+
+ if (_backgroundNeedsUpdate)
+ UpdateBackground();
+ }
+
+ async void UpdateBackground()
+ {
+ if (Element == null)
+ return;
+
+ FrameworkElement element = Control ?? Container;
+ if (element == null)
+ return;
+
+ var backgroundImage = await Element.BackgroundImageSource.ToWindowsImageSourceAsync();
+
+ if (backgroundImage != null)
+ {
+ element.SetValue(_backgroundProperty, new ImageBrush { ImageSource = backgroundImage });
+ }
+ else
+ {
+ if (!Element.Background.IsEmpty)
+ {
+ element.SetValue(_backgroundProperty, Element.Background.ToBrush());
+ }
+ else
+ {
+ Color backgroundColor = Element.BackgroundColor;
+ if (!backgroundColor.IsDefault())
+ {
+ element.SetValue(_backgroundProperty, backgroundColor.ToNative());
+ }
+ else
+ {
+ object localBackground = element.ReadLocalValue(_backgroundProperty);
+ if (localBackground != null && localBackground != DependencyProperty.UnsetValue)
+ element.ClearValue(_backgroundProperty);
+ }
+ }
+ }
+
+ _backgroundNeedsUpdate = false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/CompositionHelper.cs b/src/Controls/src/Core/Platform/Windows/CompositionHelper.cs
new file mode 100644
index 000000000000..583fa3fc770f
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/CompositionHelper.cs
@@ -0,0 +1,32 @@
+#nullable enable
+using System;
+using System.Linq;
+using System.Reflection;
+using Windows.UI.Composition;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ static class CompositionHelper
+ {
+ static bool SetTypePresent;
+ static bool IsTypePresent;
+
+ public static bool IsCompositionGeometryTypePresent
+ {
+ get
+ {
+ if (!SetTypePresent)
+ {
+ var compositorMethods = typeof(Compositor).GetMethods();
+ var createGeometricClipExists = compositorMethods.Any(m => m.Name == "CreateGeometricClip");
+ var createEllipseGeometryExists = compositorMethods.Any(m => m.Name == "CreateEllipseGeometry");
+
+ IsTypePresent = createGeometricClipExists && createEllipseGeometryExists;
+ SetTypePresent = true;
+ }
+
+ return IsTypePresent;
+ }
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/AccessibilityExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/AccessibilityExtensions.cs
new file mode 100644
index 000000000000..a1c23145dac4
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/AccessibilityExtensions.cs
@@ -0,0 +1,148 @@
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Automation.Peers;
+using NativeAutomationProperties = Microsoft.UI.Xaml.Automation.AutomationProperties;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ public static class AccessibilityExtensions
+ {
+ public static void SetAutomationPropertiesAutomationId(this FrameworkElement Control, string id)
+ {
+ Control.SetValue(NativeAutomationProperties.AutomationIdProperty, id);
+ }
+
+ public static string SetAutomationPropertiesName(this FrameworkElement Control, Element Element, string _defaultAutomationPropertiesName = null)
+ {
+ if (Element == null)
+ return _defaultAutomationPropertiesName;
+
+ if (_defaultAutomationPropertiesName == null)
+ _defaultAutomationPropertiesName = (string)Control.GetValue(NativeAutomationProperties.NameProperty);
+
+ var elemValue = (string)Element.GetValue(AutomationProperties.NameProperty);
+
+ if (!string.IsNullOrWhiteSpace(elemValue))
+ Control.SetValue(NativeAutomationProperties.NameProperty, elemValue);
+ else
+ Control.SetValue(NativeAutomationProperties.NameProperty, _defaultAutomationPropertiesName);
+
+ return _defaultAutomationPropertiesName;
+ }
+
+ public static AccessibilityView? SetAutomationPropertiesAccessibilityView(this FrameworkElement Control, Element Element, AccessibilityView? _defaultAutomationPropertiesAccessibilityView = null)
+ {
+ if (Element == null)
+ return _defaultAutomationPropertiesAccessibilityView;
+
+ if (!_defaultAutomationPropertiesAccessibilityView.HasValue)
+ _defaultAutomationPropertiesAccessibilityView = (AccessibilityView)Control.GetValue(NativeAutomationProperties.AccessibilityViewProperty);
+
+ var newValue = _defaultAutomationPropertiesAccessibilityView;
+
+ var elemValue = (bool?)Element.GetValue(AutomationProperties.IsInAccessibleTreeProperty);
+
+ if (elemValue == true)
+ newValue = AccessibilityView.Content;
+ else if (elemValue == false)
+ newValue = AccessibilityView.Raw;
+
+ Control.SetValue(NativeAutomationProperties.AccessibilityViewProperty, newValue);
+
+ return _defaultAutomationPropertiesAccessibilityView;
+
+ }
+ public static string SetAutomationPropertiesHelpText(this FrameworkElement Control, Element Element, string _defaultAutomationPropertiesHelpText = null)
+ {
+ if (Element == null)
+ return _defaultAutomationPropertiesHelpText;
+
+ if (_defaultAutomationPropertiesHelpText == null)
+ _defaultAutomationPropertiesHelpText = (string)Control.GetValue(NativeAutomationProperties.HelpTextProperty);
+
+ var elemValue = (string)Element.GetValue(AutomationProperties.HelpTextProperty);
+
+ if (!string.IsNullOrWhiteSpace(elemValue))
+ Control.SetValue(NativeAutomationProperties.HelpTextProperty, elemValue);
+ else
+ Control.SetValue(NativeAutomationProperties.HelpTextProperty, _defaultAutomationPropertiesHelpText);
+
+ return _defaultAutomationPropertiesHelpText;
+ }
+
+ public static UIElement SetAutomationPropertiesLabeledBy(
+ this FrameworkElement Control,
+ Element Element,
+ IMauiContext mauiContext,
+ UIElement _defaultAutomationPropertiesLabeledBy = null)
+ {
+ if (Element == null)
+ return _defaultAutomationPropertiesLabeledBy;
+
+ // TODO Maui: this is a bit of a hack because Elements
+ // currently don't implement IFrameworkElement but they should
+ mauiContext ??= (Element as IFrameworkElement)?.Handler?.MauiContext;
+
+ if (_defaultAutomationPropertiesLabeledBy == null)
+ _defaultAutomationPropertiesLabeledBy = (UIElement)Control.GetValue(NativeAutomationProperties.LabeledByProperty);
+
+ var elemValue = (VisualElement)Element.GetValue(AutomationProperties.LabeledByProperty);
+
+ FrameworkElement nativeElement = null;
+
+ if(mauiContext != null)
+ nativeElement = (elemValue as IView)?.GetOrCreateHandler(mauiContext)?.NativeView as FrameworkElement;
+
+ if (nativeElement != null)
+ Control.SetValue(AutomationProperties.LabeledByProperty, nativeElement);
+ else
+ Control.SetValue(NativeAutomationProperties.LabeledByProperty, _defaultAutomationPropertiesLabeledBy);
+
+ return _defaultAutomationPropertiesLabeledBy;
+ }
+
+ // TODO MAUI: This is not having any effect on anything I've tested yet. See if we need it
+ // after we test the FP and NP w/ back button explicitly enabled.
+ public static void SetBackButtonTitle(this PageControl Control, Element Element)
+ {
+ if (Element == null)
+ return;
+
+ var elemValue = ConcatenateNameAndHint(Element);
+
+ Control.BackButtonTitle = elemValue;
+ }
+
+ static string ConcatenateNameAndHint(Element Element)
+ {
+ string separator;
+
+ var name = (string)Element.GetValue(AutomationProperties.NameProperty);
+
+ var hint = (string)Element.GetValue(AutomationProperties.HelpTextProperty);
+
+
+ if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(hint))
+ separator = "";
+
+ else
+ separator = ". ";
+
+
+ return string.Join(separator, name, hint);
+
+ }
+
+ public static void SetAutomationProperties(
+ this FrameworkElement frameworkElement,
+ Element element,
+ IMauiContext mauiContext,
+ string defaultName = null)
+ {
+ frameworkElement.SetAutomationPropertiesAutomationId(element?.AutomationId);
+ frameworkElement.SetAutomationPropertiesName(element, defaultName);
+ frameworkElement.SetAutomationPropertiesHelpText(element);
+ frameworkElement.SetAutomationPropertiesLabeledBy(element, mauiContext);
+ frameworkElement.SetAutomationPropertiesAccessibilityView(element);
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/AspectExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/AspectExtensions.cs
new file mode 100644
index 000000000000..ba3fcd80c8c0
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/AspectExtensions.cs
@@ -0,0 +1,23 @@
+using WStretch = Microsoft.UI.Xaml.Media.Stretch;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal static class AspectExtensions
+ {
+ public static WStretch ToStretch(this Aspect aspect)
+ {
+ switch (aspect)
+ {
+ case Aspect.Fill:
+ return WStretch.Fill;
+
+ case Aspect.AspectFill:
+ return WStretch.UniformToFill;
+
+ case Aspect.AspectFit:
+ default:
+ return WStretch.Uniform;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/WinUI/BrushExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/BrushExtensions.cs
similarity index 93%
rename from src/Compatibility/Core/src/WinUI/BrushExtensions.cs
rename to src/Controls/src/Core/Platform/Windows/Extensions/BrushExtensions.cs
index cc73d8d79014..be1c8da6af98 100644
--- a/src/Compatibility/Core/src/WinUI/BrushExtensions.cs
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/BrushExtensions.cs
@@ -6,7 +6,7 @@
using WPoint = Windows.Foundation.Point;
using WRadialGradientBrush = Microsoft.UI.Xaml.Media.RadialGradientBrush;
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
+namespace Microsoft.Maui.Controls.Platform
{
public static class BrushExtensions
{
@@ -22,7 +22,7 @@ public static WBrush ToBrush(this Brush brush)
return null;
}
- return solidColorBrush.Color.ToBrush();
+ return solidColorBrush.Color.ToNative();
}
if (brush is LinearGradientBrush linearGradientBrush)
@@ -43,7 +43,6 @@ public static WBrush ToBrush(this Brush brush)
};
}
-#if UWP_18362
if (brush is RadialGradientBrush radialGradientBrush)
{
var wRadialGradientBrush = new WRadialGradientBrush()
@@ -61,7 +60,6 @@ public static WBrush ToBrush(this Brush brush)
return wRadialGradientBrush;
}
-#endif
return null;
}
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/ClipExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/ClipExtensions.cs
new file mode 100644
index 000000000000..475ea014eb0a
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/ClipExtensions.cs
@@ -0,0 +1,60 @@
+using Microsoft.UI.Composition;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Hosting;
+using Microsoft.Maui.Controls.Shapes;
+using WRectangleGeometry = Microsoft.UI.Xaml.Media.RectangleGeometry;
+using WVector2 = System.Numerics.Vector2;
+
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal static class ClipExtensions
+ {
+ public static void Clip(this FrameworkElement frameworkElement, Geometry geometry)
+ {
+ var wGeometry = geometry.ToNative();
+
+ if (wGeometry is WRectangleGeometry wRectangleGeometry && frameworkElement.Clip != wRectangleGeometry)
+ frameworkElement.Clip = wRectangleGeometry;
+ }
+
+ public static void ClipVisual(this FrameworkElement frameworkElement, Geometry geometry)
+ {
+ var compositor = ElementCompositionPreview.GetElementVisual(frameworkElement).Compositor;
+ var visual = ElementCompositionPreview.GetElementVisual(frameworkElement);
+
+ CompositionClip compositionClip = null;
+
+ if (geometry is EllipseGeometry ellipseGeometry)
+ {
+ var compositionEllipseGeometry = compositor.CreateEllipseGeometry();
+
+ compositionEllipseGeometry.Center = new WVector2((float)ellipseGeometry.Center.X, (float)ellipseGeometry.Center.Y);
+ compositionEllipseGeometry.Radius = new WVector2((float)ellipseGeometry.RadiusX, (float)ellipseGeometry.RadiusY);
+
+ compositionClip = compositor.CreateGeometricClip(compositionEllipseGeometry);
+ }
+ else if (geometry is LineGeometry lineGeometry)
+ {
+ var compositionLineGeometry = compositor.CreateLineGeometry();
+
+ compositionLineGeometry.Start = new WVector2((float)lineGeometry.StartPoint.X, (float)lineGeometry.StartPoint.Y);
+ compositionLineGeometry.End = new WVector2((float)lineGeometry.EndPoint.X, (float)lineGeometry.EndPoint.Y);
+
+ compositionClip = compositor.CreateGeometricClip(compositionLineGeometry);
+ }
+ else if (geometry is RectangleGeometry rectangleGeometry)
+ {
+ var compositionRectangleGeometry = compositor.CreateRectangleGeometry();
+
+ compositionRectangleGeometry.Offset = new WVector2((float)rectangleGeometry.Rect.X, (float)rectangleGeometry.Rect.Y);
+ compositionRectangleGeometry.Size = new WVector2((float)rectangleGeometry.Rect.Width, (float)rectangleGeometry.Rect.Height);
+
+ compositionClip = compositor.CreateGeometricClip(compositionRectangleGeometry);
+ }
+
+ if (visual.Clip != compositionClip)
+ visual.Clip = compositionClip;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/Extensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/Extensions.cs
new file mode 100644
index 000000000000..4b93c4719447
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/Extensions.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using System.Threading.Tasks;
+using Windows.Foundation;
+using Windows.UI.Text;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.Maui.Controls.Internals;
+using WImageSource = Microsoft.UI.Xaml.Media.ImageSource;
+using UwpScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollBarVisibility;
+using Microsoft.UI.Xaml.Media.Imaging;
+//using Microsoft.Graphics.Canvas.UI.Xaml;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal static class Extensions
+ {
+ public static ConfiguredTaskAwaitable DontSync(this IAsyncOperation self)
+ {
+ return self.AsTask().ConfigureAwait(false);
+ }
+
+ public static ConfiguredTaskAwaitable DontSync(this IAsyncAction self)
+ {
+ return self.AsTask().ConfigureAwait(false);
+ }
+
+ public static void SetBinding(this FrameworkElement self, DependencyProperty property, string path)
+ {
+ self.SetBinding(property, new Microsoft.UI.Xaml.Data.Binding { Path = new PropertyPath(path) });
+ }
+
+ public static void SetBinding(this FrameworkElement self, DependencyProperty property, string path, Microsoft.UI.Xaml.Data.IValueConverter converter)
+ {
+ self.SetBinding(property, new Microsoft.UI.Xaml.Data.Binding { Path = new PropertyPath(path), Converter = converter });
+ }
+
+ internal static InputScopeNameValue GetKeyboardButtonType(this ReturnType returnType)
+ {
+ switch (returnType)
+ {
+ case ReturnType.Default:
+ case ReturnType.Done:
+ case ReturnType.Go:
+ case ReturnType.Next:
+ case ReturnType.Send:
+ return InputScopeNameValue.Default;
+ case ReturnType.Search:
+ return InputScopeNameValue.Search;
+ default:
+ throw new NotImplementedException($"ReturnType {returnType} not supported");
+ }
+ }
+
+ internal static InputScope ToInputScope(this ReturnType returnType)
+ {
+ var scopeName = new InputScopeName()
+ {
+ NameValue = GetKeyboardButtonType(returnType)
+ };
+
+ var inputScope = new InputScope
+ {
+ Names = { scopeName }
+ };
+
+ return inputScope;
+ }
+
+ internal static UwpScrollBarVisibility ToUwpScrollBarVisibility(this Maui.Controls.ScrollBarVisibility visibility)
+ {
+ switch (visibility)
+ {
+ case Maui.Controls.ScrollBarVisibility.Always:
+ return UwpScrollBarVisibility.Visible;
+ case Maui.Controls.ScrollBarVisibility.Default:
+ return UwpScrollBarVisibility.Auto;
+ case Maui.Controls.ScrollBarVisibility.Never:
+ return UwpScrollBarVisibility.Hidden;
+ default:
+ return UwpScrollBarVisibility.Auto;
+ }
+ }
+
+ public static T Clamp(this T value, T min, T max) where T : IComparable
+ {
+ if (value.CompareTo(min) < 0)
+ return min;
+ if (value.CompareTo(max) > 0)
+ return max;
+ return value;
+ }
+
+
+ internal static int ToEm(this double pt)
+ {
+ return Convert.ToInt32( pt * 0.0624f * 1000); //Coefficient for converting Pt to Em. The value is uniform spacing between characters, in units of 1/1000 of an em.
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/FrameworkElementExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/FrameworkElementExtensions.cs
new file mode 100644
index 000000000000..3c42f95cd852
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/FrameworkElementExtensions.cs
@@ -0,0 +1,145 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.Maui.Controls.Internals;
+using WBinding = Microsoft.UI.Xaml.Data.Binding;
+using WBrush = Microsoft.UI.Xaml.Media.Brush;
+using WBindingExpression = Microsoft.UI.Xaml.Data.BindingExpression;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal static class FrameworkElementExtensions
+ {
+ static readonly Lazy> ForegroundProperties =
+ new Lazy>(() => new ConcurrentDictionary());
+
+ public static WBrush GetForeground(this FrameworkElement element)
+ {
+ if (element == null)
+ throw new ArgumentNullException("element");
+
+ return (WBrush)element.GetValue(GetForegroundProperty(element));
+ }
+
+ public static WBinding GetForegroundBinding(this FrameworkElement element)
+ {
+ WBindingExpression expr = element.GetBindingExpression(GetForegroundProperty(element));
+ if (expr == null)
+ return null;
+
+ return expr.ParentBinding;
+ }
+
+ public static object GetForegroundCache(this FrameworkElement element)
+ {
+ WBinding binding = GetForegroundBinding(element);
+ if (binding != null)
+ return binding;
+
+ return GetForeground(element);
+ }
+
+ public static void RestoreForegroundCache(this FrameworkElement element, object cache)
+ {
+ var binding = cache as WBinding;
+ if (binding != null)
+ SetForeground(element, binding);
+ else
+ SetForeground(element, (WBrush)cache);
+ }
+
+ public static void SetForeground(this FrameworkElement element, WBrush foregroundBrush)
+ {
+ if (element == null)
+ throw new ArgumentNullException("element");
+
+ element.SetValue(GetForegroundProperty(element), foregroundBrush);
+ }
+
+ public static void SetForeground(this FrameworkElement element, WBinding binding)
+ {
+ if (element == null)
+ throw new ArgumentNullException("element");
+
+ element.SetBinding(GetForegroundProperty(element), binding);
+ }
+
+ internal static IEnumerable GetDescendantsByName(this DependencyObject parent, string elementName) where T : DependencyObject
+ {
+ int myChildrenCount = VisualTreeHelper.GetChildrenCount(parent);
+ for (int i = 0; i < myChildrenCount; i++)
+ {
+ var child = VisualTreeHelper.GetChild(parent, i);
+ var controlName = child.GetValue(FrameworkElement.NameProperty) as string;
+ if (controlName == elementName && child is T)
+ yield return child as T;
+ else
+ {
+ foreach (var subChild in child.GetDescendantsByName(elementName))
+ yield return subChild;
+ }
+ }
+ }
+
+ internal static T GetFirstDescendant(this DependencyObject element) where T : FrameworkElement
+ {
+ int count = VisualTreeHelper.GetChildrenCount(element);
+ for (var i = 0; i < count; i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(element, i);
+
+ T target = child as T ?? GetFirstDescendant(child);
+ if (target != null)
+ return target;
+ }
+
+ return null;
+ }
+
+ static DependencyProperty GetForegroundProperty(FrameworkElement element)
+ {
+ if (element is Control)
+ return Control.ForegroundProperty;
+ if (element is TextBlock)
+ return TextBlock.ForegroundProperty;
+
+ Type type = element.GetType();
+
+ DependencyProperty foregroundProperty;
+ if (!ForegroundProperties.Value.TryGetValue(type, out foregroundProperty))
+ {
+ FieldInfo field = ReflectionExtensions.GetFields(type).FirstOrDefault(f => f.Name == "ForegroundProperty");
+ if (field == null)
+ throw new ArgumentException("type is not a Foregroundable type");
+
+ var property = (DependencyProperty)field.GetValue(null);
+ ForegroundProperties.Value.TryAdd(type, property);
+
+ return property;
+ }
+
+ return foregroundProperty;
+ }
+
+ internal static IEnumerable GetChildren(this DependencyObject parent) where T : DependencyObject
+ {
+ int myChildrenCount = VisualTreeHelper.GetChildrenCount(parent);
+ for (int i = 0; i < myChildrenCount; i++)
+ {
+ var child = VisualTreeHelper.GetChild(parent, i);
+ if (child is T)
+ yield return child as T;
+ else
+ {
+ foreach (var subChild in child.GetChildren())
+ yield return subChild;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/WinUI/GeometryExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/GeometryExtensions.cs
similarity index 82%
rename from src/Compatibility/Core/src/WinUI/GeometryExtensions.cs
rename to src/Controls/src/Core/Platform/Windows/Extensions/GeometryExtensions.cs
index e505ea28d78f..54664a8bee98 100644
--- a/src/Compatibility/Core/src/WinUI/GeometryExtensions.cs
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/GeometryExtensions.cs
@@ -1,12 +1,17 @@
+using System;
using Microsoft.Maui.Controls.Shapes;
using WFoundation = Windows.Foundation;
using WMedia = Microsoft.UI.Xaml.Media;
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
+namespace Microsoft.Maui.Controls.Platform
{
public static class GeometryExtensions
{
- public static WMedia.Geometry ToWindows(this Geometry geometry)
+ [Obsolete("ToWindows is obsolete. Please use ToNative instead")]
+ public static WMedia.Geometry ToWindows(this Geometry geometry) =>
+ geometry.ToNative();
+
+ public static WMedia.Geometry ToNative(this Geometry geometry)
{
WMedia.Geometry wGeometry = null;
@@ -15,8 +20,8 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
LineGeometry lineGeometry = geometry as LineGeometry;
wGeometry = new WMedia.LineGeometry
{
- StartPoint = lineGeometry.StartPoint.ToWindows(),
- EndPoint = lineGeometry.EndPoint.ToWindows()
+ StartPoint = lineGeometry.StartPoint.ToNative(),
+ EndPoint = lineGeometry.EndPoint.ToNative()
};
}
else if (geometry is RectangleGeometry)
@@ -32,7 +37,7 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
EllipseGeometry ellipseGeometry = geometry as EllipseGeometry;
wGeometry = new WMedia.EllipseGeometry
{
- Center = ellipseGeometry.Center.ToWindows(),
+ Center = ellipseGeometry.Center.ToNative(),
RadiusX = ellipseGeometry.RadiusX,
RadiusY = ellipseGeometry.RadiusY
};
@@ -47,7 +52,7 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
foreach (Geometry children in geometryGroup.Children)
{
- WMedia.Geometry winChild = children.ToWindows();
+ WMedia.Geometry winChild = children.ToNative();
(wGeometry as WMedia.GeometryGroup).Children.Add(winChild);
}
}
@@ -64,7 +69,7 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
{
WMedia.PathFigure wPathFigure = new WMedia.PathFigure
{
- StartPoint = xamPathFigure.StartPoint.ToWindows(),
+ StartPoint = xamPathFigure.StartPoint.ToNative(),
IsFilled = xamPathFigure.IsFilled,
IsClosed = xamPathFigure.IsClosed
};
@@ -79,7 +84,7 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
WMedia.LineSegment winSegment = new WMedia.LineSegment
{
- Point = lineSegment.Point.ToWindows()
+ Point = lineSegment.Point.ToNative()
};
wPathFigure.Segments.Add(winSegment);
@@ -93,7 +98,7 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
foreach (var point in polyLineSegment.Points)
{
- wSegment.Points.Add(point.ToWindows());
+ wSegment.Points.Add(point.ToNative());
}
wPathFigure.Segments.Add(wSegment);
@@ -106,9 +111,9 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
WMedia.BezierSegment wSegment = new WMedia.BezierSegment
{
- Point1 = bezierSegment.Point1.ToWindows(),
- Point2 = bezierSegment.Point2.ToWindows(),
- Point3 = bezierSegment.Point3.ToWindows()
+ Point1 = bezierSegment.Point1.ToNative(),
+ Point2 = bezierSegment.Point2.ToNative(),
+ Point3 = bezierSegment.Point3.ToNative()
};
wPathFigure.Segments.Add(wSegment);
@@ -121,7 +126,7 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
foreach (var point in polyBezierSegment.Points)
{
- wSegment.Points.Add(point.ToWindows());
+ wSegment.Points.Add(point.ToNative());
}
wPathFigure.Segments.Add(wSegment);
@@ -134,8 +139,8 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
WMedia.QuadraticBezierSegment wSegment = new WMedia.QuadraticBezierSegment
{
- Point1 = quadraticBezierSegment.Point1.ToWindows(),
- Point2 = quadraticBezierSegment.Point2.ToWindows()
+ Point1 = quadraticBezierSegment.Point1.ToNative(),
+ Point2 = quadraticBezierSegment.Point2.ToNative()
};
wPathFigure.Segments.Add(wSegment);
@@ -148,7 +153,7 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
foreach (var point in polyQuadraticBezierSegment.Points)
{
- wSegment.Points.Add(point.ToWindows());
+ wSegment.Points.Add(point.ToNative());
}
wPathFigure.Segments.Add(wSegment);
@@ -164,7 +169,7 @@ public static WMedia.Geometry ToWindows(this Geometry geometry)
RotationAngle = arcSegment.RotationAngle,
IsLargeArc = arcSegment.IsLargeArc,
SweepDirection = arcSegment.SweepDirection == SweepDirection.Clockwise ? WMedia.SweepDirection.Clockwise : WMedia.SweepDirection.Counterclockwise,
- Point = arcSegment.Point.ToWindows()
+ Point = arcSegment.Point.ToNative()
};
wPathFigure.Segments.Add(wSegment);
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/ImageExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/ImageExtensions.cs
new file mode 100644
index 000000000000..cce1a59eeb4d
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/ImageExtensions.cs
@@ -0,0 +1,130 @@
+using System;
+using Microsoft.Graphics.Canvas.UI.Xaml;
+using Microsoft.UI.Xaml.Media.Imaging;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using System.Threading.Tasks;
+using Windows.Foundation;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.Maui.Controls.Internals;
+using WImageSource = Microsoft.UI.Xaml.Media.ImageSource;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal static class ImageExtensions
+ {
+ public static Graphics.Size GetImageSourceSize(this WImageSource source)
+ {
+ if (source is null)
+ {
+ return Graphics.Size.Zero;
+ }
+ else if (source is BitmapSource bitmap)
+ {
+ return new Graphics.Size
+ {
+ Width = bitmap.PixelWidth,
+ Height = bitmap.PixelHeight
+ };
+ }
+ else if (source is CanvasImageSource canvas)
+ {
+ return new Graphics.Size
+ {
+ Width = canvas.Size.Width,
+ Height = canvas.Size.Height
+ };
+ }
+
+ throw new InvalidCastException($"\"{source.GetType().FullName}\" is not supported.");
+ }
+
+ public static Microsoft.UI.Xaml.Controls.IconSource ToWindowsIconSource(this ImageSource source)
+ {
+ return source.ToWindowsIconSourceAsync().GetAwaiter().GetResult();
+ }
+
+ public static async Task ToWindowsIconSourceAsync(this ImageSource source, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (source == null || source.IsEmpty)
+ return null;
+
+ var handler = Registrar.Registered.GetHandlerForObject(source);
+ if (handler == null)
+ return null;
+
+ try
+ {
+ return await handler.LoadIconSourceAsync(source, cancellationToken);
+ }
+ catch (OperationCanceledException)
+ {
+ // no-op
+ }
+
+ return null;
+ }
+
+ public static IconElement ToWindowsIconElement(this ImageSource source)
+ {
+ return source.ToWindowsIconElementAsync().GetAwaiter().GetResult();
+ }
+
+ public static async Task ToWindowsIconElementAsync(this ImageSource source, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (source == null || source.IsEmpty)
+ return null;
+
+ var handler = Registrar.Registered.GetHandlerForObject(source);
+ if (handler == null)
+ return null;
+
+ try
+ {
+ return await handler.LoadIconElementAsync(source, cancellationToken);
+ }
+ catch (OperationCanceledException)
+ {
+ // no-op
+ }
+
+ return null;
+ }
+
+ public static WImageSource ToWindowsImageSource(this ImageSource source)
+ {
+ return source.ToWindowsImageSourceAsync().GetAwaiter().GetResult();
+ }
+
+ public static async Task ToWindowsImageSourceAsync(this ImageSource source, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (source == null || source.IsEmpty)
+ return null;
+
+ var handler = Registrar.Registered.GetHandlerForObject(source);
+ if (handler == null)
+ return null;
+
+ try
+ {
+ return await handler.LoadImageAsync(source, cancellationToken);
+ }
+ catch (OperationCanceledException)
+ {
+ Log.Warning("Image loading", "Image load cancelled");
+ }
+ catch (Exception ex)
+ {
+ Log.Warning("Image loading", $"Image load failed: {ex}");
+#if DEBUG
+ throw;
+#endif
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/PointExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/PointExtensions.cs
new file mode 100644
index 000000000000..e00e2d0f5219
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/PointExtensions.cs
@@ -0,0 +1,12 @@
+using System;
+using Microsoft.Maui.Graphics;
+using WPoint = Windows.Foundation.Point;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ public static class PointExtensions
+ {
+ [Obsolete("ToWindows is obsolete. Please use ToNative instead")]
+ public static WPoint ToWindows(this Point point) => point.ToNative();
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/TextBlockExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/TextBlockExtensions.cs
new file mode 100644
index 000000000000..dd033806716c
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/TextBlockExtensions.cs
@@ -0,0 +1,50 @@
+using System;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal static class TextBlockExtensions
+ {
+ public static void UpdateLineBreakMode(this TextBlock textBlock, LineBreakMode lineBreakMode)
+ {
+ if (textBlock == null)
+ return;
+
+ switch (lineBreakMode)
+ {
+ case LineBreakMode.NoWrap:
+ textBlock.TextTrimming = TextTrimming.Clip;
+ textBlock.TextWrapping = TextWrapping.NoWrap;
+ break;
+ case LineBreakMode.WordWrap:
+ textBlock.TextTrimming = TextTrimming.None;
+ textBlock.TextWrapping = TextWrapping.Wrap;
+ break;
+ case LineBreakMode.CharacterWrap:
+ textBlock.TextTrimming = TextTrimming.WordEllipsis;
+ textBlock.TextWrapping = TextWrapping.Wrap;
+ break;
+ case LineBreakMode.HeadTruncation:
+ // TODO: This truncates at the end.
+ textBlock.TextTrimming = TextTrimming.WordEllipsis;
+ DetermineTruncatedTextWrapping(textBlock);
+ break;
+ case LineBreakMode.TailTruncation:
+ textBlock.TextTrimming = TextTrimming.CharacterEllipsis;
+ DetermineTruncatedTextWrapping(textBlock);
+ break;
+ case LineBreakMode.MiddleTruncation:
+ // TODO: This truncates at the end.
+ textBlock.TextTrimming = TextTrimming.WordEllipsis;
+ DetermineTruncatedTextWrapping(textBlock);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ static void DetermineTruncatedTextWrapping(TextBlock textBlock) =>
+ textBlock.TextWrapping = textBlock.MaxLines > 1 ? TextWrapping.Wrap : TextWrapping.NoWrap;
+ }
+}
diff --git a/src/Compatibility/Core/src/WinUI/Extensions/TransformExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/TransformExtensions.cs
similarity index 68%
rename from src/Compatibility/Core/src/WinUI/Extensions/TransformExtensions.cs
rename to src/Controls/src/Core/Platform/Windows/Extensions/TransformExtensions.cs
index c1d9ca83f432..2081b5d68fcb 100644
--- a/src/Compatibility/Core/src/WinUI/Extensions/TransformExtensions.cs
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/TransformExtensions.cs
@@ -1,16 +1,9 @@
using Microsoft.Maui.Controls.Shapes;
-#if WINDOWS_UWP
using WMatrix = Microsoft.UI.Xaml.Media.Matrix;
using WMatrixTransform = Microsoft.UI.Xaml.Media.MatrixTransform;
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
-#else
-using WMatrix = System.Windows.Media.Matrix;
-using WMatrixTransform = System.Windows.Media.MatrixTransform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.WPF
-#endif
+namespace Microsoft.Maui.Controls.Platform
{
public static class TransformExtensions
{
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/ViewExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/ViewExtensions.cs
new file mode 100644
index 000000000000..28e42188fdc8
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/ViewExtensions.cs
@@ -0,0 +1,20 @@
+using System.Collections.Generic;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal static class ViewExtensions
+ {
+ public static IEnumerable GetParentPages(this IView target)
+ {
+ var result = new List();
+ var parent = target.Parent as IPage;
+ while (!Application.IsApplicationOrNull(parent))
+ {
+ result.Add(parent);
+ parent = parent.Parent as IPage;
+ }
+
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/VisualElementExtensions.cs b/src/Controls/src/Core/Platform/Windows/Extensions/VisualElementExtensions.cs
new file mode 100644
index 000000000000..6c29acfb9222
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/VisualElementExtensions.cs
@@ -0,0 +1,48 @@
+using System;
+using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ public static class VisualElementExtensions
+ {
+ public static IViewHandler GetOrCreateHandler(this IView self, IMauiContext mauiContext)
+ {
+ if (self == null)
+ throw new ArgumentNullException("self");
+
+ if (self.Handler != null)
+ return self.Handler;
+
+ self.ToNative(mauiContext);
+ return self.Handler;
+ }
+
+ // TODO MAUI Make this work against IVIEW
+ internal static void Cleanup(this VisualElement self)
+ {
+ if (self == null)
+ throw new ArgumentNullException("self");
+
+ IViewHandler handler = self.Handler;
+
+ foreach (Element element in self.Descendants())
+ {
+ var visual = element as VisualElement;
+ if (visual == null)
+ continue;
+
+ visual.Handler = null;
+ }
+
+ self.Handler = null;
+ }
+
+ internal static bool UseFormsVsm(this T element) where T : VisualElement, IElementConfiguration
+ {
+ // Determine whether we're letting the VSM handle the colors or doing it the old way
+ // or disabling the legacy color management and doing it the old-old (pre 2.0) way
+ return element.HasVisualStateGroups()
+ || !element.OnThisPlatform().GetIsLegacyColorModeEnabled();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/Extensions/WinUIHelpers.cs b/src/Controls/src/Core/Platform/Windows/Extensions/WinUIHelpers.cs
new file mode 100644
index 000000000000..e12a5f6439b0
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Extensions/WinUIHelpers.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WThickness = Microsoft.UI.Xaml.Thickness;
+using WCornerRadius = Microsoft.UI.Xaml.CornerRadius;
+using WGridLength = Microsoft.UI.Xaml.GridLength;
+using UwpGridUnitType = Microsoft.UI.Xaml.GridUnitType;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ static class WinUIHelpers
+ {
+ public static WThickness CreateThickness(double left, double top, double right, double bottom)
+ {
+ return new WThickness
+ {
+ Left = left,
+ Top = top,
+ Right = right,
+ Bottom = bottom
+ };
+ }
+
+ public static WThickness CreateThickness(double all)
+ {
+ return new WThickness
+ {
+ Left = all,
+ Top = all,
+ Right = all,
+ Bottom = all
+ };
+ }
+ public static WCornerRadius CreateCornerRadius(double left, double top, double right, double bottom)
+ {
+ return new WCornerRadius
+ {
+ TopLeft = left,
+ TopRight = top,
+ BottomRight = right,
+ BottomLeft = bottom
+ };
+ }
+
+ public static WCornerRadius CreateCornerRadius(double all)
+ {
+ return new WCornerRadius
+ {
+ TopLeft = all,
+ TopRight = all,
+ BottomRight = all,
+ BottomLeft = all
+ };
+ }
+
+ public static WGridLength CreateGridLength(int v, UwpGridUnitType auto)
+ {
+ return new WGridLength(v, auto);
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/IDontGetFocus.cs b/src/Controls/src/Core/Platform/Windows/IDontGetFocus.cs
new file mode 100644
index 000000000000..d1229d0f97a2
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/IDontGetFocus.cs
@@ -0,0 +1,6 @@
+namespace Microsoft.Maui.Controls.Platform
+{
+ public interface IDontGetFocus
+ {
+ }
+}
diff --git a/src/Compatibility/Core/src/WinUI/IIconElementHandler.cs b/src/Controls/src/Core/Platform/Windows/IIconElementHandler.cs
similarity index 87%
rename from src/Compatibility/Core/src/WinUI/IIconElementHandler.cs
rename to src/Controls/src/Core/Platform/Windows/IIconElementHandler.cs
index c352fdb4b032..642395bbb505 100644
--- a/src/Compatibility/Core/src/WinUI/IIconElementHandler.cs
+++ b/src/Controls/src/Core/Platform/Windows/IIconElementHandler.cs
@@ -2,7 +2,7 @@
using System.Threading.Tasks;
using Microsoft.UI.Xaml.Controls;
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
+namespace Microsoft.Maui.Controls.Platform
{
public interface IIconElementHandler : IRegisterable
{
diff --git a/src/Compatibility/Core/src/WinUI/IImageSourceHandler.cs b/src/Controls/src/Core/Platform/Windows/IImageSourceHandler.cs
similarity index 81%
rename from src/Compatibility/Core/src/WinUI/IImageSourceHandler.cs
rename to src/Controls/src/Core/Platform/Windows/IImageSourceHandler.cs
index e28e30f767cc..0afa367f6efe 100644
--- a/src/Compatibility/Core/src/WinUI/IImageSourceHandler.cs
+++ b/src/Controls/src/Core/Platform/Windows/IImageSourceHandler.cs
@@ -1,7 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
+namespace Microsoft.Maui.Controls.Platform
{
public interface IImageSourceHandler : IRegisterable
{
diff --git a/src/Controls/src/Core/Platform/Windows/ITabStopOnDescendants.cs b/src/Controls/src/Core/Platform/Windows/ITabStopOnDescendants.cs
new file mode 100644
index 000000000000..1bddbd1b0e67
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ITabStopOnDescendants.cs
@@ -0,0 +1,6 @@
+namespace Microsoft.Maui.Controls.Platform
+{
+ public interface ITabStopOnDescendants : IDontGetFocus
+ {
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/ITitleIconProvider.cs b/src/Controls/src/Core/Platform/Windows/ITitleIconProvider.cs
new file mode 100644
index 000000000000..89db007f9787
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ITitleIconProvider.cs
@@ -0,0 +1,7 @@
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal interface ITitleIconProvider
+ {
+ Microsoft.UI.Xaml.Media.ImageSource TitleIcon { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/ITitleProvider.cs b/src/Controls/src/Core/Platform/Windows/ITitleProvider.cs
new file mode 100644
index 000000000000..c4cbfc5e8ba8
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ITitleProvider.cs
@@ -0,0 +1,15 @@
+using WBrush = Microsoft.UI.Xaml.Media.Brush;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal interface ITitleProvider
+ {
+ WBrush BarBackgroundBrush { set; }
+
+ WBrush BarForegroundBrush { set; }
+
+ bool ShowTitle { get; set; }
+
+ string Title { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/ITitleViewProvider.cs b/src/Controls/src/Core/Platform/Windows/ITitleViewProvider.cs
new file mode 100644
index 000000000000..558a514ec898
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ITitleViewProvider.cs
@@ -0,0 +1,7 @@
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal interface ITitleViewProvider
+ {
+ View TitleView { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/ITitleViewRendererController.cs b/src/Controls/src/Core/Platform/Windows/ITitleViewRendererController.cs
new file mode 100644
index 000000000000..60adf5b3f54c
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ITitleViewRendererController.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal interface ITitleViewRendererController
+ {
+ View TitleView { get; }
+ FrameworkElement TitleViewPresenter { get; }
+ Visibility TitleViewVisibility { get; set; }
+ CommandBar CommandBar { get; }
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/IToolBarForegroundBinder.cs b/src/Controls/src/Core/Platform/Windows/IToolBarForegroundBinder.cs
new file mode 100644
index 000000000000..0eabc80b4ce2
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/IToolBarForegroundBinder.cs
@@ -0,0 +1,10 @@
+using Microsoft.UI.Xaml.Controls;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal interface IToolBarForegroundBinder
+ {
+ void BindForegroundColor(AppBar appBar);
+ void BindForegroundColor(AppBarButton button);
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/IToolbarProvider.cs b/src/Controls/src/Core/Platform/Windows/IToolbarProvider.cs
new file mode 100644
index 000000000000..e205053cce1f
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/IToolbarProvider.cs
@@ -0,0 +1,10 @@
+using System.Threading.Tasks;
+using Microsoft.UI.Xaml.Controls;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal interface IToolbarProvider
+ {
+ Task GetCommandBarAsync();
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/ImageConverter.cs b/src/Controls/src/Core/Platform/Windows/ImageConverter.cs
new file mode 100644
index 000000000000..59bd32c13766
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ImageConverter.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.Maui.Controls.Internals;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ public class ImageConverter : Microsoft.UI.Xaml.Data.IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, string language)
+ {
+ return value is ImageSource source
+ ? source.ToWindowsImageSourceAsync().AsAsyncValue()
+ : null;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ throw new NotSupportedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/ImageSourceIconElementConverter.cs b/src/Controls/src/Core/Platform/Windows/ImageSourceIconElementConverter.cs
new file mode 100644
index 000000000000..e618b851f715
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ImageSourceIconElementConverter.cs
@@ -0,0 +1,20 @@
+using System;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal class ImageSourceIconElementConverter : Microsoft.UI.Xaml.Data.IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, string language)
+ {
+ if (value is ImageSource source)
+ return source.ToWindowsIconElement();
+
+ return null;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/MauiCommandBar.cs b/src/Controls/src/Core/Platform/Windows/MauiCommandBar.cs
new file mode 100644
index 000000000000..ac02f3e56442
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/MauiCommandBar.cs
@@ -0,0 +1,150 @@
+using System;
+using Windows.Foundation.Collections;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Media;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ public class MauiCommandBar : CommandBar
+ {
+ Microsoft.UI.Xaml.Controls.Button _moreButton;
+ Microsoft.UI.Xaml.Controls.ItemsControl _primaryItemsControl;
+ bool _isInValidLocation;
+
+ public MauiCommandBar()
+ {
+ PrimaryCommands.VectorChanged += OnCommandsChanged;
+ SecondaryCommands.VectorChanged += OnCommandsChanged;
+ UpdateVisibility();
+ WatchForContentChanges();
+ }
+
+ // Set by the container if the container is a valid place to show a toolbar.
+ // This exists to provide consistency with the other platforms; we've got
+ // rules in place that limit toolbars to Navigation Page and to Tabbed
+ // and Flyout-Detail Pages when they're currently displaying a Navigation Page
+ public bool IsInValidLocation
+ {
+ get { return _isInValidLocation; }
+ set
+ {
+ _isInValidLocation = value;
+ UpdateVisibility();
+ }
+ }
+
+ protected override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _moreButton = GetTemplateChild("MoreButton") as Microsoft.UI.Xaml.Controls.Button;
+ _primaryItemsControl = GetTemplateChild("PrimaryItemsControl") as Microsoft.UI.Xaml.Controls.ItemsControl;
+ }
+
+ void OnCommandsChanged(IObservableVector sender, IVectorChangedEventArgs args)
+ {
+ UpdateVisibility();
+ }
+
+ void UpdateVisibility()
+ {
+ // Determine whether we have a title (or some other content) inside this command bar
+ var frameworkElement = Content as FrameworkElement;
+
+ // Apply the rules for consistency with other platforms
+
+ // Not in one of the acceptable toolbar locations from the other platforms
+ if (!IsInValidLocation)
+ {
+ // If there's no title to display (e.g., toolbarplacement is set to bottom)
+ // or the title is collapsed (e.g., because it's empty)
+ if (frameworkElement == null || frameworkElement.Visibility != Visibility.Visible)
+ {
+ // Just collapse the whole thing
+ Visibility = Visibility.Collapsed;
+ return;
+ }
+
+ // The title needs to be visible, but we're not allowed to show a toolbar
+ // So we need to hide the toolbar items
+
+ Visibility = Visibility.Visible;
+
+ if (_moreButton != null)
+ {
+ _moreButton.Visibility = Visibility.Collapsed;
+ }
+
+ if (_primaryItemsControl != null)
+ {
+ _primaryItemsControl.Visibility = Visibility.Collapsed;
+ }
+
+ return;
+ }
+
+ // We're in one of the acceptable toolbar locations from the other platforms so the normal rules apply
+
+ if (_primaryItemsControl != null)
+ {
+ // This is normally visible by default, but it might have been collapsed by the toolbar consistency rules above
+ _primaryItemsControl.Visibility = Visibility.Visible;
+ }
+
+ // Are there any commands to display?
+ var visibility = PrimaryCommands.Count + SecondaryCommands.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
+
+ if (_moreButton != null)
+ {
+ // The "..." button should only be visible if we have commands to display
+ _moreButton.Visibility = visibility;
+
+ // There *is* an OverflowButtonVisibility property that does more or less the same thing,
+ // but it became available in 10.0.14393.0 and we have to support 10.0.10240
+ }
+
+ if (frameworkElement != null && frameworkElement.Visibility != Visibility.Collapsed)
+ {
+ // If there's a title to display, we have to be visible whether or not we have commands
+ Visibility = Visibility.Visible;
+ }
+ else
+ {
+ // Otherwise, visibility depends on whether we have commands
+ Visibility = visibility;
+ }
+ }
+
+ void WatchForContentChanges()
+ {
+ // If the content of the command bar changes while it's collapsed, we need to
+ // react and update the visibility (e.g., if the bar is placed at the bottom and
+ // has no commands, then is moved to the top and now includes the title)
+
+ // There's no event on CommandBar when the content changes, so we'll bind our own
+ // dependency property to Content and update our visibility when it changes
+ var binding = new Microsoft.UI.Xaml.Data.Binding
+ {
+ Source = this,
+ Path = new PropertyPath(nameof(Content)),
+ Mode = Microsoft.UI.Xaml.Data.BindingMode.OneWay
+ };
+
+ BindingOperations.SetBinding(this, s_contentChangeWatcher, binding);
+ }
+
+ static readonly DependencyProperty s_contentChangeWatcher =
+ DependencyProperty.Register(
+ "ContentChangeWatcher",
+ typeof(object),
+ typeof(object),
+ new PropertyMetadata(null, ContentChanged));
+
+ static void ContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ (d as MauiCommandBar)?.UpdateVisibility();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/MauiPresenter.cs b/src/Controls/src/Core/Platform/Windows/MauiPresenter.cs
new file mode 100644
index 000000000000..4c46fa6b9250
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/MauiPresenter.cs
@@ -0,0 +1,30 @@
+using System;
+using Microsoft.UI.Xaml;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Graphics;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal class MauiPresenter : Microsoft.UI.Xaml.Controls.ContentPresenter
+ {
+ public MauiPresenter()
+ {
+ Loaded += FormsPresenter_Loaded;
+ Unloaded += FormsPresenter_Unloaded;
+ SizeChanged += (s, e) =>
+ {
+ if (ActualWidth > 0 && ActualHeight > 0 && DataContext != null)
+ {
+ var page = (Page)DataContext;
+ ((Page)page.RealParent).ContainerArea = new Rectangle(0, 0, ActualWidth, ActualHeight);
+ }
+ };
+ }
+
+ void FormsPresenter_Loaded(object sender, RoutedEventArgs e)
+ => (DataContext as Page)?.SendAppearing();
+
+ void FormsPresenter_Unloaded(object sender, RoutedEventArgs e)
+ => (DataContext as Page)?.SendDisappearing();
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/MenuItemCommand.cs b/src/Controls/src/Core/Platform/Windows/MenuItemCommand.cs
new file mode 100644
index 000000000000..a89c25367aa5
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/MenuItemCommand.cs
@@ -0,0 +1,42 @@
+using System;
+using System.ComponentModel;
+using System.Windows.Input;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal class MenuItemCommand : ICommand
+ {
+ readonly MenuItem _menuItem;
+
+ public MenuItemCommand(MenuItem item)
+ {
+ _menuItem = item;
+ _menuItem.PropertyChanged += OnElementPropertyChanged;
+ }
+
+ public virtual bool CanExecute(object parameter)
+ {
+ return _menuItem.IsEnabled;
+ }
+
+ public event EventHandler CanExecuteChanged;
+
+ public void Execute(object parameter)
+ {
+ ((IMenuItemController)_menuItem).Activate();
+ }
+
+ void OnCanExecuteChanged()
+ {
+ EventHandler changed = CanExecuteChanged;
+ if (changed != null)
+ changed(this, EventArgs.Empty);
+ }
+
+ void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
+ OnCanExecuteChanged();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/NativeBindingExtensions.cs b/src/Controls/src/Core/Platform/Windows/NativeBindingExtensions.cs
new file mode 100644
index 000000000000..bd055420e86f
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/NativeBindingExtensions.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Microsoft.UI.Xaml;
+using Microsoft.Maui.Controls.Internals;
+using static System.String;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ public static class NativeBindingExtensions
+ {
+ // TODO MAUI
+ //public static void SetBinding(this FrameworkElement view, string propertyName, BindingBase bindingBase, string updateSourceEventName = null)
+ //{
+ // var binding = bindingBase as Binding;
+ // updateSourceEventName = updateSourceEventName ?? binding?.UpdateSourceEventName;
+
+ // if (IsNullOrEmpty(updateSourceEventName))
+ // {
+ // NativePropertyListener nativePropertyListener = null;
+ // if (bindingBase.Mode == BindingMode.TwoWay)
+ // nativePropertyListener = new NativePropertyListener(view, propertyName);
+
+ // NativeBindingHelpers.SetBinding(view, propertyName, bindingBase, nativePropertyListener as INotifyPropertyChanged);
+ // return;
+ // }
+
+ // NativeEventWrapper eventE = null;
+ // if (binding.Mode == BindingMode.TwoWay && !(view is INotifyPropertyChanged))
+ // eventE = new NativeEventWrapper(view, propertyName, updateSourceEventName);
+
+ // NativeBindingHelpers.SetBinding(view, propertyName, binding, eventE);
+ //}
+
+ public static void SetBinding(this FrameworkElement view, BindableProperty targetProperty, BindingBase binding)
+ {
+ NativeBindingHelpers.SetBinding(view, targetProperty, binding);
+ }
+
+ public static void SetValue(this FrameworkElement target, BindableProperty targetProperty, object value)
+ {
+ NativeBindingHelpers.SetValue(target, targetProperty, value);
+ }
+
+ public static void SetBindingContext(this FrameworkElement target, object bindingContext, Func> getChildren = null)
+ {
+ NativeBindingHelpers.SetBindingContext(target, bindingContext, getChildren);
+ }
+
+ internal static void TransferbindablePropertiesToWrapper(this FrameworkElement target, View wrapper)
+ {
+ NativeBindingHelpers.TransferBindablePropertiesToWrapper(target, wrapper);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/PageControl.cs b/src/Controls/src/Core/Platform/Windows/PageControl.cs
new file mode 100644
index 000000000000..2697b2f7114e
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/PageControl.cs
@@ -0,0 +1,183 @@
+using System.Threading.Tasks;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
+using WBrush = Microsoft.UI.Xaml.Media.Brush;
+using WImageSource = Microsoft.UI.Xaml.Media.ImageSource;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ public sealed class PageControl : ContentControl, IToolbarProvider, ITitleViewRendererController
+ {
+ public static readonly DependencyProperty TitleVisibilityProperty = DependencyProperty.Register(nameof(TitleVisibility), typeof(Visibility), typeof(PageControl), new PropertyMetadata(Visibility.Visible));
+
+ public static readonly DependencyProperty ToolbarBackgroundProperty = DependencyProperty.Register(nameof(ToolbarBackground), typeof(WBrush), typeof(PageControl),
+ new PropertyMetadata(default(WBrush)));
+
+ public static readonly DependencyProperty BackButtonTitleProperty = DependencyProperty.Register("BackButtonTitle", typeof(string), typeof(PageControl), new PropertyMetadata(false));
+
+ public static readonly DependencyProperty ContentMarginProperty = DependencyProperty.Register("ContentMargin", typeof(Microsoft.UI.Xaml.Thickness), typeof(PageControl),
+ new PropertyMetadata(default(Microsoft.UI.Xaml.Thickness)));
+
+ public static readonly DependencyProperty TitleIconProperty = DependencyProperty.Register(nameof(TitleIcon), typeof(WImageSource), typeof(PageControl), new PropertyMetadata(default(WImageSource)));
+
+ public static readonly DependencyProperty TitleViewProperty = DependencyProperty.Register(nameof(TitleView), typeof(View), typeof(PageControl), new PropertyMetadata(default(View), OnTitleViewPropertyChanged));
+
+ public static readonly DependencyProperty TitleViewVisibilityProperty = DependencyProperty.Register(nameof(TitleViewVisibility), typeof(Visibility), typeof(PageControl), new PropertyMetadata(Visibility.Collapsed));
+
+ public static readonly DependencyProperty TitleInsetProperty = DependencyProperty.Register("TitleInset", typeof(double), typeof(PageControl), new PropertyMetadata(default(double)));
+
+ public static readonly DependencyProperty TitleBrushProperty = DependencyProperty.Register("TitleBrush", typeof(WBrush), typeof(PageControl), new PropertyMetadata(null));
+
+ CommandBar _commandBar;
+ FrameworkElement _titleViewPresenter;
+
+ ToolbarPlacement _toolbarPlacement;
+ bool _toolbarDynamicOverflowEnabled = true;
+ readonly ToolbarPlacementHelper _toolbarPlacementHelper = new ToolbarPlacementHelper();
+
+ public bool ShouldShowToolbar
+ {
+ get { return _toolbarPlacementHelper.ShouldShowToolBar; }
+ set { _toolbarPlacementHelper.ShouldShowToolBar = value; }
+ }
+
+ public WImageSource TitleIcon
+ {
+ get { return (WImageSource)GetValue(TitleIconProperty); }
+ set { SetValue(TitleIconProperty, value); }
+ }
+
+ public View TitleView
+ {
+ get { return (View)GetValue(TitleViewProperty); }
+ set { SetValue(TitleViewProperty, value); }
+ }
+
+ TaskCompletionSource _commandBarTcs;
+ Microsoft.UI.Xaml.Controls.ContentPresenter _presenter;
+ TitleViewManager _titleViewManager;
+
+ public PageControl()
+ {
+ Style = Microsoft.UI.Xaml.Application.Current.Resources["MauiControlsPageControlStyle"] as Microsoft.UI.Xaml.Style;
+ }
+
+ public string BackButtonTitle
+ {
+ get { return (string)GetValue(BackButtonTitleProperty); }
+ set { SetValue(BackButtonTitleProperty, value); }
+ }
+
+ public double ContentHeight
+ {
+ get { return _presenter != null ? _presenter.ActualHeight : 0; }
+ }
+
+ public Microsoft.UI.Xaml.Thickness ContentMargin
+ {
+ get { return (Microsoft.UI.Xaml.Thickness)GetValue(ContentMarginProperty); }
+ set { SetValue(ContentMarginProperty, value); }
+ }
+
+ public double ContentWidth
+ {
+ get { return _presenter != null ? _presenter.ActualWidth : 0; }
+ }
+
+ public WBrush ToolbarBackground
+ {
+ get { return (WBrush)GetValue(ToolbarBackgroundProperty); }
+ set { SetValue(ToolbarBackgroundProperty, value); }
+ }
+
+ public ToolbarPlacement ToolbarPlacement
+ {
+ get { return _toolbarPlacement; }
+ set
+ {
+ _toolbarPlacement = value;
+ _toolbarPlacementHelper.UpdateToolbarPlacement();
+ }
+ }
+
+ public bool ToolbarDynamicOverflowEnabled
+ {
+ get { return _toolbarDynamicOverflowEnabled; }
+ set
+ {
+ _toolbarDynamicOverflowEnabled = value;
+ UpdateToolbarDynamicOverflowEnabled();
+ }
+ }
+
+ public Visibility TitleVisibility
+ {
+ get { return (Visibility)GetValue(TitleVisibilityProperty); }
+ set { SetValue(TitleVisibilityProperty, value); }
+ }
+
+ public Visibility TitleViewVisibility
+ {
+ get { return (Visibility)GetValue(TitleViewVisibilityProperty); }
+ set { SetValue(TitleViewVisibilityProperty, value); }
+ }
+
+ public WBrush TitleBrush
+ {
+ get { return (WBrush)GetValue(TitleBrushProperty); }
+ set { SetValue(TitleBrushProperty, value); }
+ }
+
+ public double TitleInset
+ {
+ get { return (double)GetValue(TitleInsetProperty); }
+ set { SetValue(TitleInsetProperty, value); }
+ }
+
+ FrameworkElement ITitleViewRendererController.TitleViewPresenter => _titleViewPresenter;
+ CommandBar ITitleViewRendererController.CommandBar => _commandBar;
+
+ Task IToolbarProvider.GetCommandBarAsync()
+ {
+ if (_commandBar != null)
+ return Task.FromResult(_commandBar);
+
+ _commandBarTcs = new TaskCompletionSource();
+ ApplyTemplate();
+ return _commandBarTcs.Task;
+ }
+
+ protected override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _presenter = GetTemplateChild("presenter") as Microsoft.UI.Xaml.Controls.ContentPresenter;
+
+ _titleViewPresenter = GetTemplateChild("TitleViewPresenter") as FrameworkElement;
+
+ _commandBar = GetTemplateChild("CommandBar") as CommandBar;
+
+ _titleViewManager = new TitleViewManager(this);
+
+ _toolbarPlacementHelper.Initialize(_commandBar, () => ToolbarPlacement, GetTemplateChild);
+ UpdateToolbarDynamicOverflowEnabled();
+
+ TaskCompletionSource tcs = _commandBarTcs;
+ tcs?.SetResult(_commandBar);
+ }
+
+ static void OnTitleViewPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
+ {
+ ((PageControl)dependencyObject)._titleViewManager?.OnTitleViewPropertyChanged();
+ }
+
+ void UpdateToolbarDynamicOverflowEnabled()
+ {
+ if (_commandBar != null)
+ {
+ _commandBar.IsDynamicOverflowEnabled = ToolbarDynamicOverflowEnabled;
+ }
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/PlatformConfigurationExtensions.cs b/src/Controls/src/Core/Platform/Windows/PlatformConfigurationExtensions.cs
new file mode 100644
index 000000000000..9db9dc4a228a
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/PlatformConfigurationExtensions.cs
@@ -0,0 +1,11 @@
+namespace Microsoft.Maui.Controls.Platform
+{
+ public static class PlatformConfigurationExtensions
+ {
+ public static IPlatformElementConfiguration OnThisPlatform(this T element)
+ where T : Element, IElementConfiguration
+ {
+ return (element).On();
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/Styles/MauiControlsCommandBarStyle.xaml b/src/Controls/src/Core/Platform/Windows/Styles/MauiControlsCommandBarStyle.xaml
new file mode 100644
index 000000000000..e946dc7d503d
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Styles/MauiControlsCommandBarStyle.xaml
@@ -0,0 +1,890 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Controls/src/Core/Platform/Windows/Styles/MauiControlsPageControlStyle.xaml b/src/Controls/src/Core/Platform/Windows/Styles/MauiControlsPageControlStyle.xaml
new file mode 100644
index 000000000000..eb296b37cda9
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Styles/MauiControlsPageControlStyle.xaml
@@ -0,0 +1,54 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/Styles/Resources.xaml b/src/Controls/src/Core/Platform/Windows/Styles/Resources.xaml
new file mode 100644
index 000000000000..f8ac786dcf7b
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/Styles/Resources.xaml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
diff --git a/src/Controls/src/Core/Platform/Windows/TitleViewManager.cs b/src/Controls/src/Core/Platform/Windows/TitleViewManager.cs
new file mode 100644
index 000000000000..472f3904e950
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/TitleViewManager.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal class TitleViewManager
+ {
+ readonly ITitleViewRendererController _titleViewRendererController;
+
+ View TitleView => _titleViewRendererController.TitleView;
+ CommandBar CommandBar => _titleViewRendererController.CommandBar;
+ FrameworkElement TitleViewPresenter => _titleViewRendererController.TitleViewPresenter;
+
+ public TitleViewManager(ITitleViewRendererController titleViewRendererController)
+ {
+ _titleViewRendererController = titleViewRendererController;
+
+ if (TitleViewPresenter != null)
+ {
+ TitleViewPresenter.Loaded += OnTitleViewPresenterLoaded;
+ }
+
+ if (CommandBar != null)
+ {
+ CommandBar.LayoutUpdated += commandLayoutUpdated;
+ CommandBar.Unloaded += commandBarUnloaded;
+ }
+ }
+
+ internal void OnTitleViewPropertyChanged()
+ {
+ UpdateTitleViewWidth();
+ }
+
+ void OnTitleViewPresenterLoaded(object sender, RoutedEventArgs e)
+ {
+ UpdateTitleViewWidth();
+ if (TitleViewPresenter != null)
+ {
+ TitleViewPresenter.Loaded -= OnTitleViewPresenterLoaded;
+ }
+ }
+
+ void commandBarUnloaded(object sender, RoutedEventArgs e)
+ {
+ if (CommandBar != null)
+ {
+ CommandBar.LayoutUpdated -= commandLayoutUpdated;
+ CommandBar.Unloaded -= commandBarUnloaded;
+ }
+ }
+
+ void commandLayoutUpdated(object sender, object e)
+ {
+ UpdateTitleViewWidth();
+ }
+
+ void UpdateTitleViewWidth()
+ {
+ if (TitleView == null || TitleViewPresenter == null || CommandBar == null)
+ return;
+
+ if (CommandBar.ActualWidth <= 0)
+ return;
+
+ double buttonWidth = 0;
+ foreach (var item in CommandBar.GetDescendantsByName("MoreButton"))
+ if (item.Visibility == Visibility.Visible)
+ buttonWidth += item.ActualWidth;
+
+ if (!CommandBar.IsDynamicOverflowEnabled)
+ foreach (var item in CommandBar.GetDescendantsByName("PrimaryItemsControl"))
+ buttonWidth += item.ActualWidth;
+
+ TitleViewPresenter.Width = CommandBar.ActualWidth - buttonWidth;
+ UpdateVisibility();
+ }
+
+ void UpdateVisibility()
+ {
+ if (TitleView == null)
+ _titleViewRendererController.TitleViewVisibility = Visibility.Collapsed;
+ else
+ _titleViewRendererController.TitleViewVisibility = Visibility.Visible;
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/ToolbarManager.cs b/src/Controls/src/Core/Platform/Windows/ToolbarManager.cs
new file mode 100644
index 000000000000..b8d346aade33
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ToolbarManager.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.UI.Xaml.Controls;
+using WImage = Microsoft.UI.Xaml.Controls.Image;
+using NativeAutomationProperties = Microsoft.UI.Xaml.Automation.AutomationProperties;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ // TODO MAUI
+ // this needs to be fixed to handle multi page
+ static internal class ToolbarManager
+ {
+ static ToolbarTracker _toolbarTracker = new ToolbarTracker();
+ static ImageConverter _imageConverter = new ImageConverter();
+ static ImageSourceIconElementConverter _imageSourceIconElementConverter = new ImageSourceIconElementConverter();
+
+ static internal async Task UpdateToolbarItems(NavigationPage page)
+ {
+ _toolbarTracker.Target = page.CurrentPage;
+ var toolbarProvider = GetToolbarProvider(page);
+
+ if (toolbarProvider == null)
+ {
+ return;
+ }
+
+ var commandBar = await toolbarProvider.GetCommandBarAsync();
+
+ if (commandBar == null)
+ {
+ return;
+ }
+
+ commandBar.PrimaryCommands.Clear();
+ commandBar.SecondaryCommands.Clear();
+
+ var toolBarForegroundBinder = GetToolbarProvider(page) as IToolBarForegroundBinder;
+
+ foreach (ToolbarItem item in _toolbarTracker.ToolbarItems)
+ {
+ toolBarForegroundBinder?.BindForegroundColor(commandBar);
+
+ var button = new AppBarButton();
+ button.SetBinding(AppBarButton.LabelProperty, "Text");
+
+ if (commandBar.IsDynamicOverflowEnabled && item.Order == ToolbarItemOrder.Secondary)
+ {
+ button.SetBinding(AppBarButton.IconProperty, "IconImageSource", _imageSourceIconElementConverter);
+ }
+ else
+ {
+ var img = new WImage();
+ img.SetBinding(WImage.SourceProperty, "Value");
+ img.SetBinding(WImage.DataContextProperty, "IconImageSource", _imageConverter);
+ button.Content = img;
+ }
+
+ button.Command = new MenuItemCommand(item);
+ button.DataContext = item;
+ button.SetValue(NativeAutomationProperties.AutomationIdProperty, item.AutomationId);
+ button.SetAutomationPropertiesName(item);
+ button.SetAutomationPropertiesAccessibilityView(item);
+ button.SetAutomationPropertiesHelpText(item);
+
+ // TODO MAUI
+ button.SetAutomationPropertiesLabeledBy(item, null);
+
+ ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order;
+ if (order == ToolbarItemOrder.Primary)
+ {
+ toolBarForegroundBinder?.BindForegroundColor(button);
+ commandBar.PrimaryCommands.Add(button);
+ }
+ else
+ {
+ commandBar.SecondaryCommands.Add(button);
+ }
+ }
+ }
+
+ static internal IToolbarProvider GetToolbarProvider(Page page)
+ {
+ IToolbarProvider provider = null;
+
+ Page element = page;
+ while (element != null)
+ {
+ provider = element.Handler as IToolbarProvider;
+ if (provider != null)
+ break;
+
+ var pageContainer = element as IPageContainer;
+ element = pageContainer?.CurrentPage;
+ }
+
+ return provider;
+ }
+
+ }
+}
diff --git a/src/Controls/src/Core/Platform/Windows/ToolbarPlacementHelper.cs b/src/Controls/src/Core/Platform/Windows/ToolbarPlacementHelper.cs
new file mode 100644
index 000000000000..bfa5086fb26d
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ToolbarPlacementHelper.cs
@@ -0,0 +1,121 @@
+using System;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal class ToolbarPlacementHelper
+ {
+ Border _bottomCommandBarArea;
+ CommandBar _commandBar;
+ Func _getToolbarPlacement;
+ Border _titleArea;
+ Border _topCommandBarArea;
+
+ public void Initialize(CommandBar commandBar, Func getToolbarPlacement,
+ Func getTemplateChild)
+ {
+ _commandBar = commandBar;
+ _getToolbarPlacement = getToolbarPlacement;
+ _bottomCommandBarArea = getTemplateChild("BottomCommandBarArea") as Border;
+ _topCommandBarArea = getTemplateChild("TopCommandBarArea") as Border;
+ _titleArea = getTemplateChild("TitleArea") as Border;
+
+ if (_commandBar != null && _bottomCommandBarArea != null && _topCommandBarArea != null)
+ {
+ // We have to wait for the command bar to load so that it'll be in the control hierarchy
+ // otherwise we can't properly move it to wherever the toolbar is supposed to be
+ _commandBar.Loaded += (sender, args) =>
+ {
+ UpdateToolbarPlacement();
+ UpdateIsInValidLocation();
+ };
+ }
+ }
+
+ public void UpdateToolbarPlacement()
+ {
+ if (_commandBar == null || _getToolbarPlacement == null || _bottomCommandBarArea == null ||
+ _topCommandBarArea == null)
+ {
+ // Template hasn't been applied yet, so we're not ready to update the toolbar placement
+ return;
+ }
+
+ UpdateToolbarPlacement(_commandBar, _getToolbarPlacement(), _bottomCommandBarArea, _topCommandBarArea, _titleArea);
+ }
+
+ static void UpdateToolbarPlacement(CommandBar toolbar, ToolbarPlacement toolbarPlacement, Border bottomCommandBarArea,
+ Border topCommandBarArea, Border titleArea)
+ {
+ // Figure out what's hosting the command bar right now
+ var current = toolbar.Parent as Border;
+
+ // And figure out where it should be
+ Border target;
+
+ switch (toolbarPlacement)
+ {
+ case ToolbarPlacement.Top:
+ target = topCommandBarArea;
+ break;
+ case ToolbarPlacement.Bottom:
+ target = bottomCommandBarArea;
+ break;
+ case ToolbarPlacement.Default:
+ default:
+ target = Device.Idiom == TargetIdiom.Phone ? bottomCommandBarArea : topCommandBarArea;
+ break;
+ }
+
+ if (current == null || target == null || current == target)
+ {
+ return;
+ }
+
+ // Remove the command bar from its current host and add it to the new one
+ current.Child = null;
+ target.Child = toolbar;
+
+ if (titleArea != null)
+ {
+ if (target == bottomCommandBarArea)
+ {
+ // If the title is hosted in the command bar and we're moving the command bar to the bottom,
+ // put the title into the topCommandBarArea
+ toolbar.Content = null;
+ topCommandBarArea.Child = titleArea;
+ }
+ else
+ {
+ // Put the title back into the command bar
+ toolbar.Content = titleArea;
+ }
+ }
+ }
+
+ // For the time being, keeping this logic for dealing with consistency between the platforms
+ // re: toolbar visibility here; at some point we should be separating toolbars from navigation bars,
+ // and this won't be necessary
+ bool _shouldShowToolBar;
+ public bool ShouldShowToolBar
+ {
+ get { return _shouldShowToolBar; }
+ set
+ {
+ _shouldShowToolBar = value;
+ UpdateIsInValidLocation();
+ }
+ }
+
+ void UpdateIsInValidLocation()
+ {
+ var MauiCommandBar = _commandBar as MauiCommandBar;
+ if (MauiCommandBar != null)
+ {
+ MauiCommandBar.IsInValidLocation = ShouldShowToolBar;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/ToolbarTracker.cs b/src/Controls/src/Core/Platform/Windows/ToolbarTracker.cs
new file mode 100644
index 000000000000..e1866765aae6
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/ToolbarTracker.cs
@@ -0,0 +1,211 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Linq;
+using Microsoft.Maui.Controls.Internals;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ internal class ToolbarTracker
+ {
+ int _flyoutDetails;
+ Page _target;
+ ToolBarItemComparer _toolBarItemComparer;
+ public ToolbarTracker()
+ {
+ _toolBarItemComparer = new ToolBarItemComparer();
+ }
+
+ public IEnumerable AdditionalTargets { get; set; }
+
+ public bool HaveFlyoutPage
+ {
+ get { return _flyoutDetails > 0; }
+ }
+
+ public bool SeparateFlyoutPage { get; set; }
+
+
+ [Obsolete("MASTERDETAILPAGE")]
+ public bool HaveMasterDetail => SeparateFlyoutPage;
+
+ [Obsolete("MASTERDETAILPAGE")]
+ public bool SeparateMasterDetail
+ {
+ get => SeparateFlyoutPage;
+ set => SeparateFlyoutPage = value;
+ }
+
+ public Page Target
+ {
+ get { return _target; }
+ set
+ {
+ if (_target == value)
+ return;
+
+ UntrackTarget(_target);
+ _target = value;
+
+ if (_target != null)
+ TrackTarget(_target);
+ EmitCollectionChanged();
+ }
+ }
+
+ public IEnumerable ToolbarItems
+ {
+ get
+ {
+ if (Target == null)
+ return new ToolbarItem[0];
+
+ // I realize this is sorting on every single get but we don't have
+ // a mechanism in place currently to invalidate a stored version of this
+
+ List returnValue = GetCurrentToolbarItems(Target);
+
+ if (AdditionalTargets != null)
+ foreach (var item in AdditionalTargets)
+ foreach (var toolbarItem in item.ToolbarItems)
+ returnValue.Add(toolbarItem);
+
+ returnValue.Sort(_toolBarItemComparer);
+ return returnValue;
+ }
+ }
+
+ public event EventHandler CollectionChanged;
+
+ void EmitCollectionChanged()
+ => CollectionChanged?.Invoke(this, EventArgs.Empty);
+
+ List GetCurrentToolbarItems(Page page)
+ {
+ var result = new List();
+ result.AddRange(page.ToolbarItems);
+
+ if (page is FlyoutPage)
+ {
+ var flyoutDetail = (FlyoutPage)page;
+ if (SeparateFlyoutPage)
+ {
+ if (flyoutDetail.IsPresented)
+ {
+ if (flyoutDetail.Flyout != null)
+ result.AddRange(GetCurrentToolbarItems(flyoutDetail.Flyout));
+ }
+ else
+ {
+ if (flyoutDetail.Detail != null)
+ result.AddRange(GetCurrentToolbarItems(flyoutDetail.Detail));
+ }
+ }
+ else
+ {
+ if (flyoutDetail.Flyout != null)
+ result.AddRange(GetCurrentToolbarItems(flyoutDetail.Flyout));
+ if (flyoutDetail.Detail != null)
+ result.AddRange(GetCurrentToolbarItems(flyoutDetail.Detail));
+ }
+ }
+ else if (page is IPageContainer)
+ {
+ var container = (IPageContainer)page;
+ if (container.CurrentPage != null)
+ result.AddRange(GetCurrentToolbarItems(container.CurrentPage));
+ }
+
+ return result;
+ }
+
+ void OnChildAdded(object sender, ElementEventArgs eventArgs)
+ {
+ var page = eventArgs.Element as Page;
+ if (page == null)
+ return;
+
+ RegisterChildPage(page);
+ }
+
+ void OnChildRemoved(object sender, ElementEventArgs eventArgs)
+ {
+ var page = eventArgs.Element as Page;
+ if (page == null)
+ return;
+
+ UnregisterChildPage(page);
+ }
+
+ void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
+ {
+ EmitCollectionChanged();
+ }
+
+ void OnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
+ {
+ if (propertyChangedEventArgs.PropertyName == NavigationPage.CurrentPageProperty.PropertyName || propertyChangedEventArgs.PropertyName == FlyoutPage.IsPresentedProperty.PropertyName ||
+ propertyChangedEventArgs.PropertyName == "Detail" || propertyChangedEventArgs.PropertyName == "Flyout")
+ {
+ EmitCollectionChanged();
+ }
+ }
+
+ void RegisterChildPage(Page page)
+ {
+ if (page is FlyoutPage)
+ _flyoutDetails++;
+
+ ((ObservableCollection)page.ToolbarItems).CollectionChanged += OnCollectionChanged;
+ page.PropertyChanged += OnPropertyChanged;
+ }
+
+ void TrackTarget(Page page)
+ {
+ if (page == null)
+ return;
+
+ if (page is FlyoutPage)
+ _flyoutDetails++;
+
+ ((ObservableCollection)page.ToolbarItems).CollectionChanged += OnCollectionChanged;
+ page.Descendants().OfType().ForEach(RegisterChildPage);
+
+ page.DescendantAdded += OnChildAdded;
+ page.DescendantRemoved += OnChildRemoved;
+ page.PropertyChanged += OnPropertyChanged;
+ }
+
+ void UnregisterChildPage(Page page)
+ {
+ if (page is FlyoutPage)
+ _flyoutDetails--;
+
+ ((ObservableCollection)page.ToolbarItems).CollectionChanged -= OnCollectionChanged;
+ page.PropertyChanged -= OnPropertyChanged;
+ }
+
+ void UntrackTarget(Page page)
+ {
+ if (page == null)
+ return;
+
+ if (page is FlyoutPage)
+ _flyoutDetails--;
+
+ ((ObservableCollection)page.ToolbarItems).CollectionChanged -= OnCollectionChanged;
+ page.Descendants().OfType().ForEach(UnregisterChildPage);
+
+ page.DescendantAdded -= OnChildAdded;
+ page.DescendantRemoved -= OnChildRemoved;
+ page.PropertyChanged -= OnPropertyChanged;
+ }
+
+ class ToolBarItemComparer : IComparer
+ {
+ public int Compare(ToolbarItem x, ToolbarItem y) => x.Priority.CompareTo(y.Priority);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/WinUI/VisualElementChangedEventArgs.cs b/src/Controls/src/Core/Platform/Windows/VisualElementChangedEventArgs.cs
similarity index 90%
rename from src/Compatibility/Core/src/WinUI/VisualElementChangedEventArgs.cs
rename to src/Controls/src/Core/Platform/Windows/VisualElementChangedEventArgs.cs
index f795933f94c6..e20f8f17af8c 100644
--- a/src/Compatibility/Core/src/WinUI/VisualElementChangedEventArgs.cs
+++ b/src/Controls/src/Core/Platform/Windows/VisualElementChangedEventArgs.cs
@@ -1,6 +1,6 @@
using System;
-namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
+namespace Microsoft.Maui.Controls.Platform
{
public class VisualElementChangedEventArgs : ElementChangedEventArgs
{
diff --git a/src/Controls/src/Core/Platform/Windows/VisualElementTracker.cs b/src/Controls/src/Core/Platform/Windows/VisualElementTracker.cs
new file mode 100644
index 000000000000..e307a550e3ea
--- /dev/null
+++ b/src/Controls/src/Core/Platform/Windows/VisualElementTracker.cs
@@ -0,0 +1,905 @@
+#nullable enable
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Windows.ApplicationModel.DataTransfer;
+using Windows.Graphics.Imaging;
+using Windows.Storage.Streams;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Hosting;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Media.Imaging;
+using Microsoft.Maui.Controls.Internals;
+using WCompositeTransform = Microsoft.UI.Xaml.Media.CompositeTransform;
+using WScaleTransform = Microsoft.UI.Xaml.Media.ScaleTransform;
+using Microsoft.Maui.Graphics;
+
+namespace Microsoft.Maui.Controls.Platform
+{
+ // TODO MAUI: can we convert this over to using IView
+ public class VisualElementTracker : IDisposable where TElement : VisualElement where TNativeElement : FrameworkElement
+ {
+ readonly NotifyCollectionChangedEventHandler _collectionChangedHandler;
+ readonly List _fingers = new List();
+ FrameworkElement? _container;
+ TNativeElement? _control;
+ TElement? _element;
+
+ bool _invalidateArrangeNeeded = false;
+
+ bool _isDisposed = false;
+ bool _isPanning = false;
+ bool _isSwiping = false;
+ bool _isPinching = false;
+ bool _wasPanGestureStartedSent = false;
+ bool _wasPinchGestureStartedSent = false;
+ public event EventHandler? Updated;
+
+ static bool HasClip;
+
+ public VisualElementTracker()
+ {
+ _collectionChangedHandler = ModelGestureRecognizersOnCollectionChanged;
+ }
+
+ public FrameworkElement? Container
+ {
+ get { return _container; }
+ set
+ {
+ if (_container == value)
+ return;
+
+ ClearContainerEventHandlers();
+
+ _container = value;
+
+ UpdatingGestureRecognizers();
+
+ UpdateNativeControl();
+ }
+ }
+
+ public bool PreventGestureBubbling { get; set; }
+
+ public TNativeElement? Control
+ {
+ get { return _control; }
+ set
+ {
+ if (_control == value)
+ return;
+
+ if (_control != null)
+ {
+ _control.Tapped -= HandleTapped;
+ _control.DoubleTapped -= HandleDoubleTapped;
+ }
+
+ _control = value;
+ UpdateNativeControl();
+
+ if (PreventGestureBubbling)
+ {
+ UpdatingGestureRecognizers();
+ }
+ }
+ }
+
+ void SendEventArgs(Action func)
+ {
+ if (_container == null && _control == null)
+ return;
+
+ var view = Element as View;
+ var gestures =
+ view?
+ .GestureRecognizers?
+ .OfType();
+
+ if (gestures == null)
+ return;
+
+ foreach (var gesture in gestures)
+ {
+ func(gesture);
+ }
+ }
+
+ void HandleDragLeave(object sender, Microsoft.UI.Xaml.DragEventArgs e)
+ {
+ var package = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
+ var dragEventArgs = new DragEventArgs(package);
+
+ dragEventArgs.AcceptedOperation = (DataPackageOperation)((int)dragEventArgs.AcceptedOperation);
+ SendEventArgs(rec =>
+ {
+ if (!rec.AllowDrop)
+ {
+ return;
+ }
+
+ var operationPriorToSend = dragEventArgs.AcceptedOperation;
+ rec.SendDragLeave(dragEventArgs);
+
+ // If you set the AcceptedOperation to a value it was already set to
+ // it causes the related animation to remain visible when the dragging component leaves
+ // for example
+ // e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
+ // Even if AcceptedOperation is already set to Copy it will cause the copy animation
+ // to remain even after the the dragged element has left
+ if (operationPriorToSend != dragEventArgs.AcceptedOperation)
+ {
+ var result = (int)dragEventArgs.AcceptedOperation;
+ e.AcceptedOperation = (Windows.ApplicationModel.DataTransfer.DataPackageOperation)result;
+ }
+ });
+ }
+
+ void HandleDragOver(object sender, Microsoft.UI.Xaml.DragEventArgs e)
+ {
+ var package = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
+ var dragEventArgs = new DragEventArgs(package);
+
+ SendEventArgs(rec =>
+ {
+ if(!rec.AllowDrop)
+ {
+ e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.None;
+ return;
+ }
+
+ rec.SendDragOver(dragEventArgs);
+ var result = (int)dragEventArgs.AcceptedOperation;
+ e.AcceptedOperation = (Windows.ApplicationModel.DataTransfer.DataPackageOperation)result;
+ });
+ }
+
+ void HandleDropCompleted(UIElement sender, Microsoft.UI.Xaml.DropCompletedEventArgs e)
+ {
+ var args = new DropCompletedEventArgs();
+ SendEventArgs(rec => rec.SendDropCompleted(args));
+ }
+
+ void HandleDrop(object sender, Microsoft.UI.Xaml.DragEventArgs e)
+ {
+ var datapackage = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
+
+ var args = new DropEventArgs(datapackage?.View);
+ SendEventArgs(async rec =>
+ {
+ if (!rec.AllowDrop)
+ return;
+
+ try
+ {
+ await rec.SendDrop(args);
+ }
+ catch (Exception dropExc)
+ {
+ Internals.Log.Warning(nameof(DropGestureRecognizer), $"{dropExc}");
+ }
+ });
+ }
+
+ void HandleDragStarting(UIElement sender, Microsoft.UI.Xaml.DragStartingEventArgs e)
+ {
+ SendEventArgs(rec =>
+ {
+ if (!rec.CanDrag)
+ {
+ e.Cancel = true;
+ return;
+ }
+
+ var renderer = sender as IViewHandler;
+ var args = rec.SendDragStarting(renderer?.VirtualView);
+ e.Data.Properties["_XFPropertes_DONTUSE"] = args.Data;
+
+ if (!args.Handled && renderer != null)
+ {
+ if (renderer.NativeView is Microsoft.UI.Xaml.Controls.Image nativeImage &&
+ nativeImage.Source is BitmapImage bi && bi.UriSource != null)
+ {
+ e.Data.SetBitmap(RandomAccessStreamReference.CreateFromUri(bi.UriSource));
+ }
+ else if(!String.IsNullOrWhiteSpace(args.Data.Text))
+ {
+ Uri? uri;
+ if (Uri.TryCreate(args.Data.Text, UriKind.Absolute, out uri))
+ {
+ if (args.Data.Text.StartsWith("http", StringComparison.OrdinalIgnoreCase))
+ e.Data.SetWebLink(uri);
+ else
+ e.Data.SetApplicationLink(uri);
+ }
+ else
+ {
+ e.Data.SetText(args.Data.Text);
+ }
+ }
+ }
+
+ e.Cancel = args.Cancel;
+ e.AllowedOperations = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
+ });
+ }
+
+ public TElement? Element
+ {
+ get { return _element; }
+ set
+ {
+ if (_element == value)
+ return;
+
+ if (_element != null)
+ {
+ _element.BatchCommitted -= OnRedrawNeeded;
+ _element.PropertyChanged -= OnPropertyChanged;
+
+ var view = _element as View;
+ if (view != null)
+ {
+ var oldRecognizers = (ObservableCollection)view.GestureRecognizers;
+ oldRecognizers.CollectionChanged -= _collectionChangedHandler;
+ var gestures = (view as IGestureController)?.CompositeGestureRecognizers as ObservableCollection;
+
+ if(gestures != null)
+ gestures.CollectionChanged -= _collectionChangedHandler;
+ }
+ }
+
+ _element = value;
+
+ if (_element != null)
+ {
+ _element.BatchCommitted += OnRedrawNeeded;
+ _element.PropertyChanged += OnPropertyChanged;
+
+ var view = _element as View;
+ if (view != null)
+ {
+ var newRecognizers = (ObservableCollection)view.GestureRecognizers;
+ newRecognizers.CollectionChanged += _collectionChangedHandler;
+
+ var gestures = (view as IGestureController)?.CompositeGestureRecognizers as ObservableCollection;
+ if (gestures != null)
+ gestures.CollectionChanged += _collectionChangedHandler;
+ }
+ }
+
+ UpdateNativeControl();
+ }
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ void ClearContainerEventHandlers()
+ {
+ if (_container != null)
+ {
+ _container.DragStarting -= HandleDragStarting;
+ _container.DropCompleted -= HandleDropCompleted;
+ _container.DragOver -= HandleDragOver;
+ _container.Drop -= HandleDrop;
+ _container.Tapped -= OnTap;
+ _container.DoubleTapped -= OnDoubleTap;
+ _container.ManipulationDelta -= OnManipulationDelta;
+ _container.ManipulationStarted -= OnManipulationStarted;
+ _container.ManipulationCompleted -= OnManipulationCompleted;
+ _container.PointerPressed -= OnPointerPressed;
+ _container.PointerExited -= OnPointerExited;
+ _container.PointerReleased -= OnPointerReleased;
+ _container.PointerCanceled -= OnPointerCanceled;
+ }
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (_isDisposed)
+ return;
+
+ _isDisposed = true;
+
+ if (!disposing)
+ return;
+
+ ClearContainerEventHandlers();
+
+ if (_element != null)
+ {
+ _element.BatchCommitted -= OnRedrawNeeded;
+ _element.PropertyChanged -= OnPropertyChanged;
+
+ var view = _element as View;
+ if (view != null)
+ {
+ var oldRecognizers = (ObservableCollection)view.GestureRecognizers;
+ oldRecognizers.CollectionChanged -= _collectionChangedHandler;
+ }
+ }
+
+ if (_control != null)
+ {
+ _control.Tapped -= HandleTapped;
+ _control.DoubleTapped -= HandleDoubleTapped;
+ }
+
+ Control = null;
+ Element = null;
+ Container = null;
+ }
+
+ protected virtual void OnPropertyChanged(object? sender, PropertyChangedEventArgs e)
+ {
+ if (Element == null)
+ return;
+
+ if (Element.Batched)
+ {
+ if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName ||
+ e.PropertyName == VisualElement.HeightProperty.PropertyName)
+ {
+ _invalidateArrangeNeeded = true;
+ }
+ return;
+ }
+
+ if (Container == null)
+ return;
+
+ if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName ||
+ e.PropertyName == VisualElement.HeightProperty.PropertyName)
+ {
+ MaybeInvalidate();
+ }
+
+
+ if (e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName)
+ {
+ UpdateScaleAndRotation(Element, Container);
+ }
+ else if (e.PropertyName == VisualElement.ScaleProperty.PropertyName || e.PropertyName == VisualElement.ScaleXProperty.PropertyName || e.PropertyName == VisualElement.ScaleYProperty.PropertyName)
+ {
+ UpdateScaleAndRotation(Element, Container);
+ }
+ else if (e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName ||
+ e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName)
+ {
+ UpdateRotation(Element, Container);
+ }
+ else if (e.PropertyName == VisualElement.IsVisibleProperty.PropertyName)
+ {
+ UpdateVisibility(Element, Container);
+ }
+ else if (e.PropertyName == VisualElement.OpacityProperty.PropertyName)
+ {
+ UpdateOpacity(Element, Container);
+ }
+ else if (e.PropertyName == VisualElement.InputTransparentProperty.PropertyName)
+ {
+ UpdateInputTransparent(Element, Container);
+ }
+ else if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
+ {
+ UpdateInputTransparent(Element, Container);
+ }
+ else if (e.PropertyName == VisualElement.ClipProperty.PropertyName)
+ {
+ UpdateClip(Element, Container);
+ }
+ }
+
+ protected virtual void UpdateNativeControl()
+ {
+ if (Element == null || Container == null)
+ return;
+
+ UpdateVisibility(Element, Container);
+ UpdateOpacity(Element, Container);
+ UpdateScaleAndRotation(Element, Container);
+ UpdateInputTransparent(Element, Container);
+ UpdateClip(Element, Container);
+
+ if (_invalidateArrangeNeeded)
+ {
+ MaybeInvalidate();
+ }
+ _invalidateArrangeNeeded = false;
+
+ OnUpdated();
+ }
+
+ void HandleSwipe(ManipulationDeltaRoutedEventArgs e, View view)
+ {
+ if (_fingers.Count > 1 || view == null)
+ return;
+
+ _isSwiping = true;
+
+ foreach (SwipeGestureRecognizer recognizer in view.GestureRecognizers.GetGesturesFor())
+ {
+ ((ISwipeGestureController)recognizer).SendSwipe(view, e.Delta.Translation.X + e.Cumulative.Translation.X, e.Delta.Translation.Y + e.Cumulative.Translation.Y);
+ }
+ }
+
+ void HandlePan(ManipulationDeltaRoutedEventArgs e, View view)
+ {
+ if (view == null)
+ return;
+
+ _isPanning = true;
+
+ foreach (PanGestureRecognizer recognizer in view.GestureRecognizers.GetGesturesFor().Where(g => g.TouchPoints == _fingers.Count))
+ {
+ if (!_wasPanGestureStartedSent)
+ {
+ recognizer.SendPanStarted(view, Application.Current.PanGestureId);
+ }
+ recognizer.SendPan(view, e.Delta.Translation.X + e.Cumulative.Translation.X, e.Delta.Translation.Y + e.Cumulative.Translation.Y, Application.Current.PanGestureId);
+ }
+ _wasPanGestureStartedSent = true;
+ }
+
+ void HandlePinch(ManipulationDeltaRoutedEventArgs e, View view)
+ {
+ if (_fingers.Count < 2 || view == null)
+ return;
+
+ _isPinching = true;
+
+ Windows.Foundation.Point translationPoint = e.Container.TransformToVisual(Container).TransformPoint(e.Position);
+
+ var scaleOriginPoint = new Point(translationPoint.X / view.Width, translationPoint.Y / view.Height);
+ IEnumerable pinchGestures = view.GestureRecognizers.GetGesturesFor();
+ foreach (PinchGestureRecognizer recognizer in pinchGestures)
+ {
+ if (!_wasPinchGestureStartedSent)
+ {
+ recognizer.SendPinchStarted(view, scaleOriginPoint);
+ }
+ recognizer.SendPinch(view, e.Delta.Scale, scaleOriginPoint);
+ }
+ _wasPinchGestureStartedSent = true;
+ }
+
+ void MaybeInvalidate()
+ {
+ if (Element?.IsInNativeLayout == true)
+ return;
+
+ var parent = (FrameworkElement?)Container?.Parent;
+ parent?.InvalidateMeasure();
+ Container?.InvalidateMeasure();
+ }
+
+ void ModelGestureRecognizersOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
+ {
+ UpdatingGestureRecognizers();
+ }
+
+ void OnDoubleTap(object sender, DoubleTappedRoutedEventArgs e)
+ {
+ var view = Element as View;
+ if (view == null)
+ return;
+
+ var tapPosition = e.GetPosition(Control);
+ var children = (view as IGestureController)?.GetChildElements(new Point(tapPosition.X, tapPosition.Y));
+
+ if (children != null)
+ foreach (var recognizer in children.GetChildGesturesFor(g => g.NumberOfTapsRequired == 1 || g.NumberOfTapsRequired == 2))
+ {
+ recognizer.SendTapped(view);
+ e.Handled = true;
+ }
+
+ if (e.Handled)
+ return;
+
+ IEnumerable doubleTapGestures = view.GestureRecognizers.GetGesturesFor(g => g.NumberOfTapsRequired == 1 || g.NumberOfTapsRequired == 2);
+ foreach (TapGestureRecognizer recognizer in doubleTapGestures)
+ {
+ recognizer.SendTapped(view);
+ e.Handled = true;
+ }
+ }
+
+ void OnManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
+ {
+ SwipeComplete(true);
+ PinchComplete(true);
+ PanComplete(true);
+ }
+
+ void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
+ {
+ var view = Element as View;
+ if (view == null)
+ return;
+ HandleSwipe(e, view);
+ HandlePinch(e, view);
+ HandlePan(e, view);
+ }
+
+ void OnManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
+ {
+ var view = Element as View;
+ if (view == null)
+ return;
+ _wasPinchGestureStartedSent = false;
+ _wasPanGestureStartedSent = false;
+ }
+
+ void OnPointerCanceled(object sender, PointerRoutedEventArgs e)
+ {
+ uint id = e.Pointer.PointerId;
+ if (_fingers.Contains(id))
+ _fingers.Remove(id);
+ SwipeComplete(false);
+ PinchComplete(false);
+ PanComplete(false);
+ }
+
+ void OnPointerExited(object sender, PointerRoutedEventArgs e)
+ {
+ uint id = e.Pointer.PointerId;
+ if (_fingers.Contains(id))
+ _fingers.Remove(id);
+ SwipeComplete(true);
+ PinchComplete(true);
+ PanComplete(true);
+ }
+
+ void OnPointerPressed(object sender, PointerRoutedEventArgs e)
+ {
+ uint id = e.Pointer.PointerId;
+ if (!_fingers.Contains(id))
+ _fingers.Add(id);
+ }
+
+ void OnPointerReleased(object? sender, PointerRoutedEventArgs e)
+ {
+ uint id = e.Pointer.PointerId;
+ if (_fingers.Contains(id))
+ _fingers.Remove(id);
+ SwipeComplete(true);
+ PinchComplete(true);
+ PanComplete(true);
+ }
+
+ void OnRedrawNeeded(object? sender, EventArgs e)
+ {
+ UpdateNativeControl();
+ }
+
+ void OnTap(object? sender, TappedRoutedEventArgs e)
+ {
+ var view = Element as View;
+ if (view == null)
+ return;
+
+ var tapPosition = e.GetPosition(Control);
+ var children = (view as IGestureController)?.GetChildElements(new Point(tapPosition.X, tapPosition.Y));
+
+ if (children != null)
+ foreach (var recognizer in children.GetChildGesturesFor(g => g.NumberOfTapsRequired == 1))
+ {
+ recognizer.SendTapped(view);
+ e.Handled = true;
+ }
+
+ if (e.Handled)
+ return;
+
+ IEnumerable tapGestures = view.GestureRecognizers.GetGesturesFor(g => g.NumberOfTapsRequired == 1);
+ foreach (var recognizer in tapGestures)
+ {
+ recognizer.SendTapped(view);
+ e.Handled = true;
+ }
+ }
+
+ void SwipeComplete(bool success)
+ {
+ var view = Element as View;
+ if (view == null || !_isSwiping)
+ return;
+
+ if (success)
+ {
+ foreach (SwipeGestureRecognizer recognizer in view.GestureRecognizers.GetGesturesFor())
+ {
+ ((ISwipeGestureController)recognizer).DetectSwipe(view, recognizer.Direction);
+ }
+ }
+
+ _isSwiping = false;
+ }
+
+ void OnUpdated()
+ {
+ if (Updated != null)
+ Updated(this, EventArgs.Empty);
+ }
+
+ void PanComplete(bool success)
+ {
+ var view = Element as View;
+ if (view == null || !_isPanning)
+ return;
+
+ foreach (PanGestureRecognizer recognizer in view.GestureRecognizers.GetGesturesFor().Where(g => g.TouchPoints == _fingers.Count))
+ {
+ if (success)
+ {
+ recognizer.SendPanCompleted(view, Application.Current.PanGestureId);
+ }
+ else
+ {
+ recognizer.SendPanCanceled(view, Application.Current.PanGestureId);
+ }
+ }
+
+ Application.Current.PanGestureId++;
+ _isPanning = false;
+ }
+
+ void PinchComplete(bool success)
+ {
+ var view = Element as View;
+ if (view == null || !_isPinching)
+ return;
+
+ IEnumerable pinchGestures = view.GestureRecognizers.GetGesturesFor();
+ foreach (PinchGestureRecognizer recognizer in pinchGestures)
+ {
+ if (success)
+ {
+ recognizer.SendPinchEnded(view);
+ }
+ else
+ {
+ recognizer.SendPinchCanceled(view);
+ }
+ }
+
+ _isPinching = false;
+ }
+
+ static void UpdateInputTransparent(VisualElement view, FrameworkElement frameworkElement)
+ {
+ if (view is Layout)
+ {
+ // Let VisualElementRenderer handle this
+ }
+
+ frameworkElement.IsHitTestVisible = view.IsEnabled && !view.InputTransparent;
+ }
+
+ static void UpdateClip(VisualElement view, FrameworkElement frameworkElement)
+ {
+ if (!ShouldUpdateClip(view, frameworkElement))
+ return;
+
+ var geometry = view.Clip;
+
+ HasClip = geometry != null;
+
+ if (CompositionHelper.IsCompositionGeometryTypePresent)
+ frameworkElement.ClipVisual(geometry);
+ else
+ frameworkElement.Clip(geometry);
+ }
+
+ static bool ShouldUpdateClip(VisualElement view, FrameworkElement frameworkElement)
+ {
+ if (view == null || frameworkElement == null)
+ return false;
+
+ var formsGeometry = view.Clip;
+
+ if (formsGeometry != null)
+ return true;
+
+ if (formsGeometry == null && HasClip)
+ return true;
+
+ return false;
+ }
+
+ static void UpdateOpacity(VisualElement view, FrameworkElement frameworkElement)
+ {
+ frameworkElement.Opacity = view.Opacity;
+ }
+
+ static void UpdateRotation(VisualElement view, FrameworkElement frameworkElement)
+ {
+ double anchorX = view.AnchorX;
+ double anchorY = view.AnchorY;
+ double rotationX = view.RotationX;
+ double rotationY = view.RotationY;
+ double rotation = view.Rotation;
+ double translationX = view.TranslationX;
+ double translationY = view.TranslationY;
+ double scaleX = view.Scale * view.ScaleX;
+ double scaleY = view.Scale * view.ScaleY;
+
+ if (rotationX % 360 == 0 && rotationY % 360 == 0 && rotation % 360 == 0 && translationX == 0 && translationY == 0 && scaleX == 1 && scaleY == 1)
+ {
+ frameworkElement.Projection = null;
+ frameworkElement.RenderTransform = null;
+ }
+ else
+ {
+ // PlaneProjection removes touch and scrollwheel functionality on scrollable views such
+ // as ScrollView, ListView, and TableView. If neither RotationX or RotationY are set
+ // (i.e. their absolute value is 0), a CompositeTransform is instead used to allow for
+ // rotation of the control on a 2D plane, and the other values are set. Otherwise, the
+ // rotation values are set, but the aforementioned functionality will be lost.
+ if (Math.Abs(view.RotationX) != 0 || Math.Abs(view.RotationY) != 0)
+ {
+ frameworkElement.Projection = new PlaneProjection
+ {
+ CenterOfRotationX = anchorX,
+ CenterOfRotationY = anchorY,
+ GlobalOffsetX = translationX,
+ GlobalOffsetY = translationY,
+ RotationX = -rotationX,
+ RotationY = -rotationY,
+ RotationZ = -rotation
+ };
+ }
+ else
+ {
+ frameworkElement.RenderTransform = new WCompositeTransform
+ {
+ CenterX = anchorX,
+ CenterY = anchorY,
+ Rotation = rotation,
+ ScaleX = scaleX,
+ ScaleY = scaleY,
+ TranslateX = translationX,
+ TranslateY = translationY
+ };
+ }
+ }
+ }
+
+ static void UpdateScaleAndRotation(VisualElement view, FrameworkElement frameworkElement)
+ {
+ double anchorX = view.AnchorX;
+ double anchorY = view.AnchorY;
+ frameworkElement.RenderTransformOrigin = new Windows.Foundation.Point(anchorX, anchorY);
+ frameworkElement.RenderTransform = new WScaleTransform { ScaleX = view.Scale * view.ScaleX, ScaleY = view.Scale * view.ScaleY };
+
+ UpdateRotation(view, frameworkElement);
+ }
+
+ static void UpdateVisibility(VisualElement view, FrameworkElement frameworkElement)
+ {
+ frameworkElement.Visibility = view.IsVisible ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ void UpdateDragAndDropGestureRecognizers()
+ {
+ if (_container == null)
+ return;
+
+ var view = Element as View;
+ IList? gestures = view?.GestureRecognizers;
+
+ if (gestures == null)
+ return;
+
+ _container.CanDrag = gestures.GetGesturesFor()
+ .FirstOrDefault()?.CanDrag ?? false;
+
+ _container.AllowDrop = gestures.GetGesturesFor()
+ .FirstOrDefault()?.AllowDrop ?? false;
+
+ if (_container.CanDrag)
+ {
+ _container.DragStarting += HandleDragStarting;
+ _container.DropCompleted += HandleDropCompleted;
+ }
+
+ if(_container.AllowDrop)
+ {
+ _container.DragOver += HandleDragOver;
+ _container.Drop += HandleDrop;
+ _container.DragLeave += HandleDragLeave;
+ }
+ }
+
+ void UpdatingGestureRecognizers()
+ {
+ var view = Element as View;
+ IList? gestures = view?.GestureRecognizers;
+
+ if (_container == null || gestures == null)
+ return;
+
+ ClearContainerEventHandlers();
+ UpdateDragAndDropGestureRecognizers();
+
+ var children = (view as IGestureController)?.GetChildElements(Point.Zero);
+ IList? childGestures = children?.GetChildGesturesFor().ToList();
+
+ if (gestures.GetGesturesFor(g => g.NumberOfTapsRequired == 1).Any()
+ || children?.GetChildGesturesFor(g => g.NumberOfTapsRequired == 1).Any() == true)
+ {
+ _container.Tapped += OnTap;
+ }
+ else
+ {
+ if (_control != null && PreventGestureBubbling)
+ {
+ _control.Tapped += HandleTapped;
+ }
+ }
+
+ if (gestures.GetGesturesFor(g => g.NumberOfTapsRequired == 1 || g.NumberOfTapsRequired == 2).Any()
+ || children?.GetChildGesturesFor(g => g.NumberOfTapsRequired == 1 || g.NumberOfTapsRequired == 2).Any() == true)
+ {
+ _container.DoubleTapped += OnDoubleTap;
+ }
+ else
+ {
+ if (_control != null && PreventGestureBubbling)
+ {
+ _control.DoubleTapped += HandleDoubleTapped;
+ }
+ }
+
+ bool hasSwipeGesture = gestures.GetGesturesFor().GetEnumerator().MoveNext();
+ bool hasPinchGesture = gestures.GetGesturesFor().GetEnumerator().MoveNext();
+ bool hasPanGesture = gestures.GetGesturesFor().GetEnumerator().MoveNext();
+ if (!hasSwipeGesture && !hasPinchGesture && !hasPanGesture)
+ return;
+
+ //We can't handle ManipulationMode.Scale and System , so we don't support pinch/pan on a scrollview
+ if (Element is ScrollView)
+ {
+ if (hasPinchGesture)
+ Log.Warning("Gestures", "PinchGestureRecognizer is not supported on a ScrollView in Windows Platforms");
+ if (hasPanGesture)
+ Log.Warning("Gestures", "PanGestureRecognizer is not supported on a ScrollView in Windows Platforms");
+ if (hasSwipeGesture)
+ Log.Warning("Gestures", "SwipeGestureRecognizer is not supported on a ScrollView in Windows Platforms");
+ return;
+ }
+
+ _container.ManipulationMode = ManipulationModes.Scale | ManipulationModes.TranslateX | ManipulationModes.TranslateY;
+ _container.ManipulationDelta += OnManipulationDelta;
+ _container.ManipulationStarted += OnManipulationStarted;
+ _container.ManipulationCompleted += OnManipulationCompleted;
+ _container.PointerPressed += OnPointerPressed;
+ _container.PointerExited += OnPointerExited;
+ _container.PointerReleased += OnPointerReleased;
+ _container.PointerCanceled += OnPointerCanceled;
+ }
+
+ void HandleTapped(object sender, TappedRoutedEventArgs tappedRoutedEventArgs)
+ {
+ tappedRoutedEventArgs.Handled = true;
+ }
+
+ void HandleDoubleTapped(object sender, DoubleTappedRoutedEventArgs doubleTappedRoutedEventArgs)
+ {
+ doubleTappedRoutedEventArgs.Handled = true;
+ }
+ }
+}
diff --git a/src/Controls/src/Core/PropertyChangedEventArgsExtensions.cs b/src/Controls/src/Core/PropertyChangedEventArgsExtensions.cs
new file mode 100644
index 000000000000..b22b66838deb
--- /dev/null
+++ b/src/Controls/src/Core/PropertyChangedEventArgsExtensions.cs
@@ -0,0 +1,48 @@
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace Microsoft.Maui.Controls
+{
+ internal static class PropertyChangedEventArgsExtensions
+ {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool Is(this PropertyChangedEventArgs args, BindableProperty property)
+ {
+ return args.PropertyName == property.PropertyName;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsOneOf(this PropertyChangedEventArgs args, BindableProperty p0, BindableProperty p1)
+ {
+ return args.PropertyName == p0.PropertyName ||
+ args.PropertyName == p1.PropertyName;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsOneOf(this PropertyChangedEventArgs args, BindableProperty p0, BindableProperty p1, BindableProperty p2)
+ {
+ return args.PropertyName == p0.PropertyName ||
+ args.PropertyName == p1.PropertyName ||
+ args.PropertyName == p2.PropertyName;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsOneOf(this PropertyChangedEventArgs args, BindableProperty p0, BindableProperty p1, BindableProperty p2, BindableProperty p3)
+ {
+ return args.PropertyName == p0.PropertyName ||
+ args.PropertyName == p1.PropertyName ||
+ args.PropertyName == p2.PropertyName ||
+ args.PropertyName == p3.PropertyName;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsOneOf(this PropertyChangedEventArgs args, BindableProperty p0, BindableProperty p1, BindableProperty p2, BindableProperty p3, BindableProperty p4)
+ {
+ return args.PropertyName == p0.PropertyName ||
+ args.PropertyName == p1.PropertyName ||
+ args.PropertyName == p2.PropertyName ||
+ args.PropertyName == p3.PropertyName ||
+ args.PropertyName == p4.PropertyName;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/RadioButton.cs b/src/Controls/src/Core/RadioButton.cs
index d250e514b971..342270455692 100644
--- a/src/Controls/src/Core/RadioButton.cs
+++ b/src/Controls/src/Core/RadioButton.cs
@@ -5,7 +5,7 @@
namespace Microsoft.Maui.Controls
{
- public class RadioButton : TemplatedView, IElementConfiguration, ITextElement, IFontElement, IBorderElement
+ public partial class RadioButton : TemplatedView, IElementConfiguration, ITextElement, IFontElement, IBorderElement
{
public const string CheckedVisualState = "Checked";
public const string UncheckedVisualState = "Unchecked";
diff --git a/src/Controls/src/Core/ViewExtensions.cs b/src/Controls/src/Core/ViewExtensions.cs
index fcbe5780b4e6..74b18c26ed65 100644
--- a/src/Controls/src/Core/ViewExtensions.cs
+++ b/src/Controls/src/Core/ViewExtensions.cs
@@ -184,24 +184,24 @@ internal static IEnumerable GetParentsPath(this Element self)
}
}
- internal static string GetStringValue(this Element element)
+ internal static string GetStringValue(this IView element)
{
string text = null;
- if (element is Label label)
+ if (element is ILabel label)
text = label.Text;
- else if (element is Entry entry)
+ else if (element is IEntry entry)
text = entry.Text;
- else if (element is Editor editor)
+ else if (element is IEditor editor)
text = editor.Text;
- else if (element is TimePicker tp)
+ else if (element is ITimePicker tp)
text = tp.Time.ToString();
- else if (element is DatePicker dp)
+ else if (element is IDatePicker dp)
text = dp.Date.ToString();
- else if (element is CheckBox cb)
+ else if (element is ICheckBox cb)
text = cb.IsChecked.ToString();
- else if (element is Switch sw)
- text = sw.IsToggled.ToString();
- else if (element is RadioButton rb)
+ else if (element is ISwitch sw)
+ text = sw.IsOn.ToString();
+ else if (element is IRadioButton rb)
text = rb.IsChecked.ToString();
return text;
diff --git a/src/Controls/src/Xaml/Controls.Xaml-net6.csproj b/src/Controls/src/Xaml/Controls.Xaml-net6.csproj
index a474a48b11fc..ee3581c6616e 100644
--- a/src/Controls/src/Xaml/Controls.Xaml-net6.csproj
+++ b/src/Controls/src/Xaml/Controls.Xaml-net6.csproj
@@ -7,7 +7,7 @@
$(NoWarn);CA1416
- $(DefineConstants);WINDOWS_UWP;WINDOWS
+ $(DefineConstants);WINDOWS
10.0.17763.0
win10-x86;win10-x64;win10-arm64
diff --git a/src/Controls/tests/Core.UnitTests/DragGestureRecognizerTests.cs b/src/Controls/tests/Core.UnitTests/DragGestureRecognizerTests.cs
index 9296595b41e8..0c5c79174076 100644
--- a/src/Controls/tests/Core.UnitTests/DragGestureRecognizerTests.cs
+++ b/src/Controls/tests/Core.UnitTests/DragGestureRecognizerTests.cs
@@ -134,7 +134,7 @@ public void TextPackageCorrectlyExtractedFromCompatibleElement(Type fieldType, s
var dragRec = new DragGestureRecognizer();
var element = (VisualElement)Activator.CreateInstance(fieldType);
Assert.IsTrue(element.TrySetValue(result));
- var args = dragRec.SendDragStarting(element);
+ var args = dragRec.SendDragStarting((IView)element);
Assert.AreEqual(result, args.Data.Text);
}
diff --git a/src/Core/src/Core/IRadioButton.cs b/src/Core/src/Core/IRadioButton.cs
new file mode 100644
index 000000000000..61d5e3e470c1
--- /dev/null
+++ b/src/Core/src/Core/IRadioButton.cs
@@ -0,0 +1,15 @@
+using Microsoft.Maui.Graphics;
+
+namespace Microsoft.Maui
+{
+ ///
+ /// Represents a View that provides a toggled value.
+ ///
+ public interface IRadioButton : IView
+ {
+ ///
+ /// Gets or sets a Boolean value that indicates whether this RadioButton is checked.
+ ///
+ bool IsChecked { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Core/src/Handlers/IViewHandler.cs b/src/Core/src/Handlers/IViewHandler.cs
index 043252d8c3a7..03593171386e 100644
--- a/src/Core/src/Handlers/IViewHandler.cs
+++ b/src/Core/src/Handlers/IViewHandler.cs
@@ -10,6 +10,7 @@ public interface IViewHandler
void DisconnectHandler();
object? NativeView { get; }
IView? VirtualView { get; }
+ IMauiContext? MauiContext { get; }
bool HasContainer { get; set; }
Size GetDesiredSize(double widthConstraint, double heightConstraint);
void SetFrame(Rectangle frame);
diff --git a/src/Core/src/Handlers/View/ViewHandlerOfT.cs b/src/Core/src/Handlers/View/ViewHandlerOfT.cs
index d034e4991d4b..18f823131fa7 100644
--- a/src/Core/src/Handlers/View/ViewHandlerOfT.cs
+++ b/src/Core/src/Handlers/View/ViewHandlerOfT.cs
@@ -119,6 +119,10 @@ protected virtual void SetupDefaults(TNativeView nativeView) { }
public abstract partial class ViewHandler : ViewHandler
where TVirtualView : class, IView
{
+ internal ViewHandler()
+ {
+ }
+
public new TVirtualView? VirtualView
{
get => (TVirtualView?)base.VirtualView;
diff --git a/src/Core/src/Platform/Windows/MauiWinUIApplication.cs b/src/Core/src/Platform/Windows/MauiWinUIApplication.cs
index bbf5eaaa4042..8d9b51acc0bd 100644
--- a/src/Core/src/Platform/Windows/MauiWinUIApplication.cs
+++ b/src/Core/src/Platform/Windows/MauiWinUIApplication.cs
@@ -100,4 +100,4 @@ protected MauiWinUIApplication()
public IApplication Application { get; protected set; } = null!;
}
-}
\ No newline at end of file
+}
diff --git a/src/Core/src/Platform/Windows/MauiWinUIWindow.cs b/src/Core/src/Platform/Windows/MauiWinUIWindow.cs
index a3162aa9b2d3..e0cafdd0a127 100644
--- a/src/Core/src/Platform/Windows/MauiWinUIWindow.cs
+++ b/src/Core/src/Platform/Windows/MauiWinUIWindow.cs
@@ -15,7 +15,7 @@ public MauiWinUIWindow()
if (!Application.Current.Resources.ContainsKey("MauiRootContainerStyle"))
{
var myResourceDictionary = new Microsoft.UI.Xaml.ResourceDictionary();
- myResourceDictionary.Source = new Uri("ms-appx:///Microsoft.Maui/Platform/Windows/Styles/MauiTextBoxStyle.xbf");
+ myResourceDictionary.Source = new Uri("ms-appx:///Microsoft.Maui/Platform/Windows/Styles/Resources.xbf");
Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
}
}
diff --git a/src/Core/src/Platform/Windows/NativeVersion.cs b/src/Core/src/Platform/Windows/NativeVersion.cs
new file mode 100644
index 000000000000..628285d08942
--- /dev/null
+++ b/src/Core/src/Platform/Windows/NativeVersion.cs
@@ -0,0 +1,12 @@
+using Microsoft.UI.Xaml;
+
+namespace Microsoft.Maui
+{
+ public static class NativeVersion
+ {
+ // https://docs.microsoft.com/en-us/windows/winui/api/microsoft.ui.xaml.window.current?view=winui-3.0
+ // The currently activated window for UWP apps. Null for Desktop apps.
+ public static bool IsDesktop =>
+ Window.Current == null;
+ }
+}
diff --git a/src/Core/src/TaskExtensions.cs b/src/Core/src/TaskExtensions.cs
new file mode 100644
index 000000000000..e75040e1234e
--- /dev/null
+++ b/src/Core/src/TaskExtensions.cs
@@ -0,0 +1,26 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.Maui
+{
+ public static class TaskExtensions
+ {
+ public static async void FireAndForget(
+ this Task task,
+ Action? errorCallback
+ )
+ {
+ try
+ {
+ await task;
+ }
+ catch(Exception exc)
+ {
+ errorCallback?.Invoke(exc);
+ }
+ }
+ }
+}
diff --git a/src/Essentials/src/AppActions/AppActions.uwp.cs b/src/Essentials/src/AppActions/AppActions.uwp.cs
index 1eabe41d3988..707997994a3b 100644
--- a/src/Essentials/src/AppActions/AppActions.uwp.cs
+++ b/src/Essentials/src/AppActions/AppActions.uwp.cs
@@ -28,12 +28,12 @@ internal static async Task OnLaunched(LaunchActivatedEventArgs e)
{
var args = e?.Arguments;
#if !WINDOWS_UWP
- if (string.IsNullOrEmpty(args))
- {
- var cliArgs = Environment.GetCommandLineArgs();
- if (cliArgs?.Length > 1)
- args = cliArgs[1];
- }
+ if (string.IsNullOrEmpty(args))
+ {
+ var cliArgs = Environment.GetCommandLineArgs();
+ if (cliArgs?.Length > 1)
+ args = cliArgs[1];
+ }
#endif
if (args?.StartsWith(appActionPrefix) ?? false)
diff --git a/src/Essentials/src/MainThread/MainThread.uwp.cs b/src/Essentials/src/MainThread/MainThread.uwp.cs
index 7858de911a2e..14263842ac4c 100644
--- a/src/Essentials/src/MainThread/MainThread.uwp.cs
+++ b/src/Essentials/src/MainThread/MainThread.uwp.cs
@@ -33,7 +33,7 @@ static bool PlatformIsMainThread
return CoreApplication.MainView.CoreWindow.Dispatcher?.HasThreadAccess ?? false;
#elif WINDOWS
- return DispatcherQueue.GetForCurrentThread()?.HasThreadAccess ?? false;
+ return DispatcherQueue.GetForCurrentThread()?.HasThreadAccess ?? false;
#endif
}
}
@@ -47,13 +47,13 @@ static void PlatformBeginInvokeOnMainThread(Action action)
throw new InvalidOperationException("Unable to find main thread.");
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action()).WatchForError();
#elif WINDOWS
- var dispatcher = DispatcherQueue.GetForCurrentThread();
+ var dispatcher = DispatcherQueue.GetForCurrentThread();
- if (dispatcher == null)
- throw new InvalidOperationException("Unable to find main thread.");
+ if (dispatcher == null)
+ throw new InvalidOperationException("Unable to find main thread.");
- if (!dispatcher.TryEnqueue(DispatcherQueuePriority.Normal, () => action()))
- throw new InvalidOperationException("Unable to queue on the main thread.");
+ if (!dispatcher.TryEnqueue(DispatcherQueuePriority.Normal, () => action()))
+ throw new InvalidOperationException("Unable to queue on the main thread.");
#endif
}
}
diff --git a/src/Essentials/test/DeviceTests.Shared/HardwareSupport.cs b/src/Essentials/test/DeviceTests.Shared/HardwareSupport.cs
index 5aa15a0d466f..1f089e0c729a 100644
--- a/src/Essentials/test/DeviceTests.Shared/HardwareSupport.cs
+++ b/src/Essentials/test/DeviceTests.Shared/HardwareSupport.cs
@@ -4,86 +4,86 @@ static class HardwareSupport
{
public static bool HasAccelerometer =>
#if __ANDROID__
- // android emulates the accelerometer
- true;
+ // android emulates the accelerometer
+ true;
#elif __IOS__
- // all iOS devices (and only devices) have an accelerometer
- Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
+ // all iOS devices (and only devices) have an accelerometer
+ Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
#elif WINDOWS_UWP
- // UWP does not emulate, and only some devices have, an accelerometer
- Windows.Devices.Sensors.Accelerometer.GetDefault() != null;
+ // UWP does not emulate, and only some devices have, an accelerometer
+ Windows.Devices.Sensors.Accelerometer.GetDefault() != null;
#endif
public static bool HasMagnetometer =>
#if __ANDROID__
- // android emulates the magnetometer
- true;
+ // android emulates the magnetometer
+ true;
#elif __IOS__
- // all iOS devices (and only devices) have a magnetometer
- Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
+ // all iOS devices (and only devices) have a magnetometer
+ Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
#elif WINDOWS_UWP
- // UWP does not emulate, and only some devices have, a magnetometer
- Windows.Devices.Sensors.Magnetometer.GetDefault() != null;
+ // UWP does not emulate, and only some devices have, a magnetometer
+ Windows.Devices.Sensors.Magnetometer.GetDefault() != null;
#endif
public static bool HasGyroscope =>
#if __ANDROID__
- // Android emulators and devices have gyros
- Microsoft.Maui.Essentials.Platform.SensorManager?.GetDefaultSensor(Android.Hardware.SensorType.Gyroscope) != null;
+ // Android emulators and devices have gyros
+ Microsoft.Maui.Essentials.Platform.SensorManager?.GetDefaultSensor(Android.Hardware.SensorType.Gyroscope) != null;
#elif __IOS__
- // all iOS devices (and only devices) have a gyroscope
- Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
+ // all iOS devices (and only devices) have a gyroscope
+ Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
#elif WINDOWS_UWP
- // UWP does not emulate, and only some devices have, a gyroscope
- Windows.Devices.Sensors.Gyrometer.GetDefault() != null;
+ // UWP does not emulate, and only some devices have, a gyroscope
+ Windows.Devices.Sensors.Gyrometer.GetDefault() != null;
#endif
public static bool HasCompass =>
#if __ANDROID__
- // android emulates the compass
- true;
+ // android emulates the compass
+ true;
#elif __IOS__
- // all iOS devices (and only devices) have a compass
- Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
+ // all iOS devices (and only devices) have a compass
+ Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
#elif WINDOWS_UWP
- // UWP does not emulate, and only some devices have, a compass
- Windows.Devices.Sensors.Compass.GetDefault() != null;
+ // UWP does not emulate, and only some devices have, a compass
+ Windows.Devices.Sensors.Compass.GetDefault() != null;
#endif
public static bool HasBattery =>
#if __ANDROID__
- // android emulates the battery
- true;
+ // android emulates the battery
+ true;
#elif __IOS__
- // all iOS devices (and only devices) have a battery
- Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
+ // all iOS devices (and only devices) have a battery
+ Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
#elif WINDOWS_UWP
- // UWP appears to emulate a battery
- // TODO: verify this
- true;
+ // UWP appears to emulate a battery
+ // TODO: verify this
+ true;
#endif
public static bool HasFlash =>
#if __ANDROID__
- // TODO: android emulates the lamp, I think...
- Microsoft.Maui.Essentials.Platform.HasSystemFeature(Android.Content.PM.PackageManager.FeatureCameraFlash);
+ // TODO: android emulates the lamp, I think...
+ Microsoft.Maui.Essentials.Platform.HasSystemFeature(Android.Content.PM.PackageManager.FeatureCameraFlash);
#elif __IOS__
- // all iOS devices (and only devices) have a camera
- Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
+ // all iOS devices (and only devices) have a camera
+ Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
#elif WINDOWS_UWP
- // TODO: most UWP devices don't have a camera lamp (mobile devices do, we we don't care about those)
- false;
+ // TODO: most UWP devices don't have a camera lamp (mobile devices do, we we don't care about those)
+ false;
#endif
public static bool HasBarometer =>
#if __ANDROID__
- true;
+ true;
#elif __IOS__
- // iphone 6 and never have a barometer. looking in how to test this.
- Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
+ // iphone 6 and never have a barometer. looking in how to test this.
+ Microsoft.Maui.Essentials.DeviceInfo.DeviceType == Microsoft.Maui.Essentials.DeviceType.Physical;
#elif WINDOWS_UWP
- // TODO: most UWP devices don't have a barometer (mobile devices do, we we don't care about those)
- false;
+ // TODO: most UWP devices don't have a barometer (mobile devices do, we we don't care about those)
+ false;
#endif
}
}