Giter Site home page Giter Site logo

xamlstraddle's Introduction

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.

xamlstraddle's People

Contributors

asklar avatar krschau avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.