Is it able to check XAML Designer mode in csproj?

William Liu 346 Reputation points
2024-07-29T05:22:41.65+00:00

I have a .net 8 WPF project which is developed with lastest Visual Studio Community Version (v17.10.5).

I have learned that I can use Condition attribute in csproj file to toggle build property.

My question is, is there a Condition key word to check if current environment is in the Visual Studio XAML Designer mode, not a actual WPF running environment? I would like to introduce some design resource library which only used for helping XAML designer work, but I don't want to include this library in the actual project.

Expected:

  <ItemGroup>
    <ProjectReference Condition=" '$(XamlDesignerMode)' == 'true' "
                      Include="..\DesignerResource\DesignerResource.csproj" />
  </ItemGroup>
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,716 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,896 questions
{count} votes