Skip to content

XamlEngine/Samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

XamlEngine

8/16/2018 Update:

I have decided to release the code as open-source under the MIT license. There are still a lot of issues that need to be worked out. Over the next few weeks I will try to document everything that's there. Hopefully the community will contribute to make something we all want. And if nothing else, maybe it will be educational for folks trying to develop for WASM/Emscripten.

The code can be found here: https://github.com/XamlEngine/Core

XamlEngine has been created to enable Xaml to be rendered natively in the browser. While the goal is to keep it compatible with .NET, it has no .NET dependencies. It has been authored completely in C++ targeting OpenGL. Emscripten is used to compile a WASM package which translates the OpenGL bindings to WebGL. Because the use of OpenGL, any platform could be targeted. However, the browser is currently the highest priority.

Fonts are downloaded at runtime because there isn't access to the local system fonts. So you will see the page render first, then after the font is downloaded the Xaml engine does a invalidate/layout/render pass.

Check out the running demo here: http://www.xamlengine.com

Usage

The current version is available for use freely as-is from it's location. Use at your own risk. There is no production support for this currently.

<!doctype html>
<html lang="en-us">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>XamlEngine.com</title>
</head>
<body>
    <script type="text/xaml" pageLayout="full">
        <UserControl>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="100" />
                    <RowDefinition />
                    <RowDefinition Height="100" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Rectangle Fill="#FF000000" Grid.Row="0" />
                <TextBlock Text="XamlEngine" Foreground="#FFFFFFFF" Grid.Row="0" FontSize="24" VerticalAlignment="Center" HorizontalAlignment="Center" />
                <TextBlock Text="This page has been rendered natively from Xaml in your browser using WebAssembly & WebGL." Grid.Row="1" FontSize="24" VerticalAlignment="Center" HorizontalAlignment="Stretch" TextAlignment="Center" TextWrapping="Wrap" />
                <Rectangle Fill="#FF000000" Grid.Row="2" />
                <TextBlock Text="Copyright XamlEngine.com 2018" Foreground="#FFFFFFFF" Grid.Row="2" FontSize="18" VerticalAlignment="Bottom" />
                <TextBlock Text="More info: [email protected]" Foreground="#FFFFFFFF" Grid.Row="2" FontSize="18" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
            </Grid>
        </UserControl>
    </script>
    <script type="text/javascript" src="http://resources.xamlengine.com/scripts/alpha/1.0.0/XamlEngine.js"></script>
</body>
</html>

Features

At this point the feature set is very limited. The current features that exist are only to satisfy a proof-of-concept.

UIElement

FrameworkElement

Width

Height

VerticalAlignment

HorizontalAlignment

ContentControl

Limited support for ContentControl has been created to satisfy UserControl functionality, as UserControl inherits from ContentControl. It doesn't currently support ContentTemplates.

Properties:

Content

UserControl

Currently the UserControl is used as the root Xaml element.

Canvas

Grid

Properties:

RowDefinitions

ColumnDefinitions

Attached Properties:

Row

RowSpan

Column

ColumnSpan

Image

Very limited support for images has been created. It currently works with a handful of PNGs. But others are having issues. This is a bug that's currently being looked at. If the image doesn't render properly, a black rectangle is rendered in place.

Properties:

Source

Rectangle

Currently only supports fill with a SolidColorBrush.

Properties:

Fill

TextBlock

Properties:

Text

Foreground

FontSize

TextAlignment

TextWrapping

Current Effort

After achieving the initial proof-of-concept, the goal is to now focus on keyboard and mouse input. This also means that integrating with higher-level languages like (but not limited to) Javascript is necessary. So this effort will include access to the Xaml DOM. In addition, bug fixes, performance improvements will also continue.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages