8000 GitHub - krschau/XamlStraddle: A library to dual target system XAML and WinUI
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A library to dual target system XAML and WinUI

License

Notifications You must be signed in to change notification settings

krschau/XamlStraddle

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XamlStraddle

A library to dual target system XAML and WinUI

Description

This is a C++ header-only library that allows your app or library to seamlessly target either UWP XAML and WinUI 3. This is achieved via type and namespace aliases. Currently the library can target WinUI 3 Preview 2.

Your app can switch from UWP XAML to WinUI 3 by defining a pre-processor variable USE_WINUI3.

The syntax for packages.config does not allow runtime conditional behavior, so your project's packages.config will have to include WinUI 3 (and WinUI 2 if you use it) always, and then at build time one or the other will be used.

In your msbuild project (vcxproj) file:

  <ItemDefinitionGroup>
    <!-- Enlighten C++ code about WinUI3 -->
    <ClCompile>
      <PreprocessorDefinitions>USE_WINUI3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <!-- Enlighten IDL interfaces about WinUI3 -->
    <Midl>
      <PreprocessorDefinitions>USE_WINUI3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </Midl>
  </ItemDefinitionGroup>

How to use

Instead of including <winrt/Windows.UI.Xaml.h> etc., just include <UI.Xaml.h>. Then when use the namespace aliases, e.g. instead of winrt::Windows::UI::Xaml (or WinUI 3's winrt::Microsoft::UI::Xaml) use the xaml alias.

About

A library to dual target system XAML and WinUI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 57.6%
  • C++ 42.4%
0