Skip to content

Commit ad1a203

Browse files
authored
Fix XAML intellisense and hot reload in Visual Studio 2022 (#20851)
This fix is for MAUI devs that edit and debug sample projects in Visual Studio (like `Maui.Controls.Sample.Sandbox`). ![image](https://github.com/dotnet/maui/assets/2523431/cfa16f54-056a-4dfd-89ee-ba3a4f0d9894) Those sample projects normally don't set `UseMaui=true` since control library projects are referenced directly in the solution. We need to instead set `DefaultXamlRuntime=Maui` in order for Visual Studio intellisense and XAML hot reload to work. VS uses either `UseMaui` or `DefaultXamlRuntime` to determine the XAML runtime.
2 parents ad0a6f2 + 18d980c commit ad1a203

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

src/Compatibility/ControlGallery/src/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<SampleProject>true</SampleProject>
44
<UseMaui Condition=" '$(UseWorkload)' == 'true' ">true</UseMaui>
5+
<DefaultXamlRuntime Condition=" '$(UseWorkload)' != 'true' ">Maui</DefaultXamlRuntime>
56
</PropertyGroup>
67
<Import Project="../../../../Directory.Build.props" />
78
</Project>

src/Controls/samples/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<SampleProject>true</SampleProject>
44
<UseMaui Condition=" '$(UseWorkload)' == 'true' ">true</UseMaui>
5+
<DefaultXamlRuntime Condition=" '$(UseWorkload)' != 'true' ">Maui</DefaultXamlRuntime>
56
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0022;XC0023</WarningsNotAsErrors>
67
</PropertyGroup>
78
<Import Project="../../../Directory.Build.props" />

src/Essentials/samples/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<SampleProject>true</SampleProject>
44
<UseMaui Condition=" '$(UseWorkload)' == 'true' ">true</UseMaui>
5+
<DefaultXamlRuntime Condition=" '$(UseWorkload)' != 'true' ">Maui</DefaultXamlRuntime>
56
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0022;XC0023</WarningsNotAsErrors>
67
</PropertyGroup>
78
<Import Project="../../../Directory.Build.props" />

0 commit comments

Comments
 (0)