About Uno platform
The Uno Platform is a Universal Windows Platform Bridge to allow UWP based code to run on iOS, Android, and WebAssembly. It provides the full API definitions of the UWP Windows 10 October 2018 Update (17763), and the implementation of parts of the UWP API, such as Windows.UI.Xaml, to enable applications to run on these platforms. This allows the use the UWP tooling from Windows in Visual Studio, such as XAML Edit and Continue and C# Edit and Continue, to build an application as much as possible on Windows, then validate that the application runs on iOS, Android and WebAssembly. The XAML User Interface (UI) provides the ability to display the same XAML files on Windows, iOS, Android and WebAssembly platforms. Uno also provides support for the MVVM pattern on all platforms, with binding, styling, control and data-templating features. As the Uno Platform provides all of the APIs of the complete UWP platform, any UWP library can be compiled on top of Uno (e.g. XamlBehaviors), with the ability to determine which APIs are implemented or not via the IDE using C# Analyzers.
For users, it can provide can provide a consistent experience across platforms, particularly between mobile and desktop browsers.
For developers, it can provide a consistent development experience across all platforms, using Microsoft's tooling as a base for a more efficient development loop.
For designers, XAML can provide a shared way to use pixel-perfect designs and use rich UI interactions.
Developing for Windows (phone, desktop, tablet, XBox), iOS (tablet and phone), Android (tablet and phone) and the Web via WebAssembly at once can be a complex process, especially when it comes to the user interface. Each platform has its own ways of defining dynamic layouts, with some being more efficient, some more verbose, some more elegant, and some more performant than others. Yet, being able to master all these frameworks at once is a particularly difficult task, because of the amount of platform-specific knowledge required to master each platform. Most of the time it boils down to different teams developing the same application multiple times, with each requiring a full development cycle. With Xamarin, C# comes to all these platforms; however, it only provides transparent translations of the UI frameworks available for iOS and Android. Most non-UI code can be shared, but when it comes to the UI, almost nothing can be shared. To avoid having to learn the UI-layout techniques and approaches for each platform, Uno.UI mimics the Windows XAML approach of defining UI and layouts. This translates into the ability to share styles, layouts, and data-bindings while retaining the ability to mix XAML-style and native layouts. For instance, a StackPanel can easily contain a RelativeLayout on Android, or a MKMapView on iOS. Uno.UI provides the ability for developers to reuse known layout and coding techniques on all platforms, resulting in a gain of overall productivity when creating UI-rich applications.
Uno Platform was created by Team nventive over the past 4 years.
The Uno Platform is the only implementation of the UWP API that runs across iOS, Android and WebAssembly.
Yes, the Uno Platform is open source, under the Apache 2.0 license.
You can try the Uno Platform using the Uno Platform Playground, the Quick Start GitHub repository, or through our Visual Studio Extension.
The Uno Platform Playground is a convenient way to experiment with the Uno platform, using the only a WebAssembly compatible web browser.
Support is available through our gitter, twitter account, and email [email protected].
There are lots of ways to contribute to the Uno Platform and we appreciate the help from the community. You can provide feedback, report bugs, give suggestions, contribute code, and participate in the platform discussions.
- If you think you've found a bug, please log a new issue in the Uno Platform GitHub issue tracker. When filing issues, please use our bug filing template. The best way to get your bug fixed is to be as detailed as you can be about the problem. Providing a minimal project with steps to reproduce the problem is ideal. Here are questions you can answer before you file a bug to make sure you're not missing any important information.
- Did you read the documentation?
- Did you include the snippet of broken code in the issue?
- What are the EXACT steps to reproduce this problem?
- What specific version or build are you using?
- What operating system are you using?
GitHub supports markdown, so when filing bugs make sure you check the formatting before clicking submit.
Universal Windows Platform (UWP) is an API created by Microsoft and first introduced in Windows 10. The purpose of this platform is to help develop universal apps that run on Windows 10, Windows 10 Mobile, Xbox One and HoloLens without the need to be re-written for each. It supports Windows app development using C++, C#, VB.NET, and XAML. The API is implemented in C++, and supported in C++, VB.NET, C#, F# and JavaScript. Designed as an extension to the Windows Runtime platform first introduced in Windows Server 2012 and Windows 8, UWP allows developers to create apps that will potentially run on multiple types of devices.
Visit Microsoft's documentation for a primer on UWP : https://docs.microsoft.com/en-us/windows/uwp/get-started/
Multiple techniques can be used to render UI, ranging from rendering pixels in a Frame Buffer (Avalonia), to rendering only using platform-provided controls (Xamarin.Forms).
While the former provides a high flexibility in terms of rendering fidelity and the ability to add new platforms, it has the drawback of not following the platform native behaviors. For instance, interactions with text boxes, has to be re-implemented completely in order to match the native behavior, and has to be updated regularly to follow platform updates. This approach also makes it very difficult to integrate native UI components "in-canvas", such as Map or Browser controls.
The latter, however, provides full fidelity with the underlying platform, making it blend easily with native applications. While this can be interesting for some kinds of applications, designers usually want to have a branded pixel-perfect look and feel which stays consistent across platforms, where drawing primitives are not available.
The Uno Platform sits in the middle, using the power of XAML to provide the ability to custom draw and animate UI, while reusing key parts of the underlying UI Toolkit (such as chrome-less native text boxes) to provide native system interactions support and native accessibility features.
Uno Platform-based applications on iOS and Android are no different than any other Xamarin-based applications. See the details here.
On the Web, the application is built using the standard .NET tooling. The application is then transformed into a static website though the Uno Web Boostrapper, which uses mono-wasm to run the C# code in the browser.
WebAssembly is supported in 4 major browser engines, see the WebAssembly official site for more details.
For iOS and Android, it can be deployed like any Xamarin-based application through the App Store and Play Store, respectively.
For WebAssembly, it can be deployed using GitHub Pages, Azure Web Apps, Azure Static Web Sites, or any other static web site hosting provider.
Not yet. We're still waiting for Apple's Marzipan cross macOS-iOS APIs to become available. We’ll see from there.
No, not at the moment. Our assumption for now is that the WebAssembly part of Uno.UI will be efficient enough to be a viable alternative. If you find that native support still is a viable scenario, please open a GitHub issue.
Yes, those are called Templated Controls in the UWP dialect, because they inherit from Control Uno.UI currently handles styles a bit differently from what WPF/UWP is doing and Uno.UI parser does not handle <Style.Setters>
properly. These should not be impacting as long as you have a resource dictionary file containing your style. See here: https://github.com/nventive/Uno/blob/master/doc/articles/api-differences.md#styles
Yes, use the VisibleBoundsPadding behavior to manage the notch correctly.
The end goal is to implement most features of the UWP API, but the road map article details what is upcoming.
XAML stands for eXtensible Application Markup Language, and is used to provide a declarative way to define user interfaces. Its ability to provide a clear separation of concerns between the UI definition and application logic using data binding provides a good experience for small to very large applications where integrators can easily create UI without having to deal with C# code.
For a good introduction to the use of XAML and MVVM patterns see Microsoft's Laurent Bugnion presentation.
Over the years, Microsoft has been working on different implementations that use XAML for defining User Interfaces, and currently, three main flavors co-exist: WPF, UWP, Xamarin.Forms and the legacy Silverlight.
All these implementations use the same base XAML definition language, with minor differences in terns of the interpretation of the XML namespaces (clr-namespace
vs. using:
), and major differences in terms of the APIs used by the XAML parser.
For instance, WPF has System.Windows.Controls.StackPanel
, UWP
has Windows.UI.Xaml.Controls.StackPanel
and Xamarin.Forms
has Xamarin.Forms.StackLayout
. All three essentially behave in the same way, but have implementation differences and feature differences, though UWP, WPF and Silverlight have a very similar behavior.
Mono is currently the best (and only) mobile-friendly implementation of .NET that targets iOS, Android and WebAssembly. It shares a lot -- and increasing -- of code from the BCL implementation with .NET core, making the runtime behavior very similar and in most cases, identical across platforms.
Our ultimate goal is to allow for the UWP api to run on all platforms, using Microsoft's own UWP implementation as a reference.
Our definition of a bridge is the ability to reuse UWP-compatible source code unmodified, and allow it to compile on a different platform, yet behave at runtime the same way.
This definition comes from what microsoft used to call when working on Islandwood and Astoria bridges to make iOS and Android code or binaries run on Windows.
Microsoft describes it best in its What is .NET page:
.NET is a free, cross-platform, open source developer platform for building many different types of applications. With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, gaming, and IoT.
Not at the moment. iOS and Android platform support relies on the underlying APIs being visible through class hierarchy for performance reasons. Also, the .NET Standard model is based on binary sharing, which makes very difficult to use platform features without jumping through hoops such as Dependency Injection, Inversion of Control or reflection.
Yes, here's a project sample. https://github.com/nventive/Uno.Samples/tree/master/UI/ControlLibrary. It is also possible to create a new Cross-Platform class library using the Uno Platform Visual Studio extension.
You may want to try our latest dev builds, and here's how to do it:
- On your solution node, select Manage Nuget packages for Solution
- Next to the Search text box, check the Include prerelease box
- You should now see the latest Uno.UI package in the Updates tab.
There's an issue in Visual Studio that makes the C# edit and continue for the UWP head fail with an error message if the Android, iOS or Wasm heads are loaded. Temporary unload those projects to use C# edit and continue in the Windows head.
You need to make sure that:
- Your Windows project's
- target SDK version is above Fall Creators Update (16299)
- has been built once successfully
- the
Microsoft.NETCore.UniversalWindowsPlatform
package version is above 6.0
- That you've closed all XAML editor Windows after having build the application
- That the project selector at the left of the XAML editor is selecting your windows project
If you're still having issues, restart Visual Studio and/or unload the iOS/Android and WASM projects, using right-click on the project, then unload.
Yes! The current performance is limited by the runtime interpreted mode of mono-wasm. The Mono team is working on implementing AOT compilation, which will improve significantly the performance. See Miguel de Icaza's status update for more details.
You can subscribe to this mono issue's updates for progress.
This is a known Chromium issue, which should be improving with the release of Chrome 69.
If you're getting this error:
Error: System.Threading.Tasks.TaskSchedulerException: An exception was thrown by a TaskScheduler. ---> System.SystemException: Thread creation failed.
at System.Threading.Thread.StartInternal (System.Security.Principal.IPrincipal principal, System.Threading.StackCrawlMark& stackMark) <0x1a68870 + 0x00028> in <bd95bcd953c94273b1c4cdb69e9b2632>:0
Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsole (Microsoft.Extensions.Logging.ILoggerFactory factory, System.Func`3[T1,T2,TResult] filter, System.Boolean includeScopes)
Keep the version 1.1.1 of Microsoft.Extensions.Logging; latest version of Logging Extensions is starting a new thread and it's not supported in Wasm.
For live update on UWP you need to edit the xaml while the project is debugging, no need for save, it updates on every keystroke (more or less) you need to update to the latest UWP sdk in your project configuration, change target version to latest
- Install Uno.UI Solution Template Visual Studio Extension https://github.com/nventive/Uno/releases
- Look for Uno.UI App Solution under Visual C#
- if you still havent found it, try and use the Search box
First create a shared project and move all .cs and .xaml files into it and reference the project in your UWP head project. Ensure everything is still working and add other projects for other platforms referencing the same shared project.
- Create a project with Uno.UI template.
- Copying as much code as possible from the existing UWP app to the "My Project.Shared"
- Add platform specific code using suffixing files in the shared project (ex: ".iOS.cs")
- ios/android specific heads should be relatively empty, only used os specific implementation (push notification handling/deeplinking/permissions)
- Test, debug and publish.
This is essentially the same process as porting an app(add steps anyways), but using cross-targeted projects. Use this project as a base for your cross-targeted library.
Yes it is possible, but you need to use the provided HttpHandler by Uno.UI like what we did in the Uno.UI Playground:
var handler = new Wasm.WasmHttpHandler();
var httpClient = new HttpClient(handler);
- If the API is present in .NET Standard, it is generally suggested to use this one instead of the UWP one. (e.g System.IO or System.Net.HttpClient)Missing APIs will be implemented based on the popularity of suggestions in the Uno.UI issues list. Make sure to open one for the APIs you need.
Yes, through the ApiInformation
class.
Some work has been done to mitigate those issues, but in some instances, the mono-wasm can be heuristically considered as a crypto-miner, or other type of malware.
If you encounter this type of issue, please open an issue with your setup's relevant installed software and versions.
I'm getting the following error:
System.InvalidOperationException: The project(s) [...] did not provide any metadata reference.
To work around this, you must include all the platforms you want to support in your TargetFrameworks node. See this question.
Uno.UI is making use of the Open-Source WinJS symbols font, which must be installed in your application directly:
- See the Playground for an actual use example.
- See the documentation for adding fonts for iOS, Android and WebAssembly.
The best way is to create a QuickStart app using the Uno.UI template, take the style from the Microsoft generic.xaml
,
place it in a resource dictionary and see what the XAML parser is telling.
Navigation is done through Frame
Frame is more or less the same as a NavigationPage in Xamarin.Forms, and MasterDetails page in Xamarin.Forms is a SplitView
in UWP.
Working with a shared project is not much different than working with PCLs, it's simply more flexible as you have access to all platforms, preferably via partial classes.
Make sure you also reference libraries in each Head project ( myproject.iOS.csproj, myproject.Android.csproj, myproject.UWP.csproj), sharedprojects don't own references to libraries.
Error targets 'netstandard2.0'. It cannot be referenced by a project that targets 'UAP,Version=v10.0.14393'
Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: netstandard, Version=2.0.0.0, Culture=neutral, [...]
System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=[...]'. The located assembly's manifest definition does not match the assembly reference.
Make sure to upgrade your SDK version and nuget packages. You have to target Fall Creators update or later and reference the netcore package to 6.0+.
when I navigate this ways _frame.Navigate(typeof(MainPage));
I never call MainPage ctor. How to inject MainPage datacontext then?
The DataContext
can be passed as a navigation parameter, then set as DataContext
in the OnNavigatedTo
method
I'm trying to ref a net standard library into my iOS project but it says "The project(s) MyApp.Services.Interfaces did not provide any metadata reference".
It's an existing issue, caused by Roslyn. You must add all your TargetFrameworks to your netstd2.0 project, and use Oren's MSBuid.Extras for that source generation issue
Can Uno.UI convert a UWP control to native android/ios and also has the option to use android native controls within xaml?
That's exactly right, see this for the XAML-UWP button, and this for the iOS native button When complete XAML is used for rendering, it's not so much a conversion but more of a vector rendering. For instance, Uno.UI.iOS uses CGLayer for rendering content it's different because Uno.UI integrates within the layouting system of the platform, which allows for mixed rendering. Uno.UI supports webviews, whereas Flutter does not. Flutter also has to render everything, including what the platform provides by default, such as the Magnifier in the TextBox for accessibility (this is not yet supported either).
And can I access the camera, take a picture and Post to a REST WebAPI? can I access Photos / files in phone?
For now, we have internal code to do all of that, but in the meantime, you have to do this by hand on each. Parts of https://docs.microsoft.com/en-us/xamarin/essentials/ allows to do it.
There's a bug on Android where PointerReleased
is not fired if PointerPressed
is not handled.
Try this:
PointerPressed += (s, e) => { e.Handled = true; };
Only Wasm, Android and iOS projects need a reference to Uno.UI. Adding a reference to the Uno.UI package provides access to the
VisibleBoundsPadding
attached property for notch'ed devices.
You can add them using the add button. Only properties explicitly defined in the xaml will show up at first
The event on button is called Click
This is part of the Uno.SourceGeneration package, and it's used to generate code like XAML to C#.
In the XAML file error CS0246: The type or namespace name '[...]' could not be found (are you missing a using directive or an assembly reference?)
clr-namespace:
is not supported by UWP, using:
is.
For now, persistence is enable only for ApplicationData.LocalFolder
, ApplicationData.RoamingFolder
and ApplicationData.SharedLocalFolder
folders.
You can write files in those folders using both StorageFile
and File.IO
.
Files that are located in other directories are going to use the in-memory filesystem of emscripten and won't be persisted.
As ApplicationData.LocalSettings
and ApplicationData.RoamingSettings
are persisted in their respective folder, they are also persisted.
Not yet. Any plans to?
Yes, debugging works for iOS and Android, as in any Xamarin native application. Debugging for WebAssembly is not supported yet.
MVVMLight, Prism and ReactiveUI are supported, MvvmCross is coming.
It's partially implemented but there are parts that are closed source from Microsoft. In the meantime, make sure your Windows head is using the latest Min SDK, at which point you'll be able to use the UWP designer.
Yes, if you do not see it:
- Make sure you are targetting the latest windows SDK version.
- Choose "XAML Designer" as the default for opening your XAML files (right-click on your XAML file and then "Open With").
- Relaunch your Visual Studio solution.
- Select UWP on the top-left corner of your XAML file.
Program does not contain a static 'Main' method suitable for an entry point
when building the UWP project.
This means that the shared project is not referenced by the UWP head, right click references on the UWP project, shared projects, then select it there.
Not yet, but using XAML conditionals and XamarinMediaManager, it's possible to have a similar experience.
Many of the application developed during the private phase of the Uno.UI Platform require credentials to be used, but here are some of the public ones:
- https://itunes.apple.com/ca/app/jean-coutu/id351461407
- https://itunes.apple.com/ca/app/my-md-mobile/id1144752656
- https://itunes.apple.com/us/app/vca-careclub/id1172429469
Yes, as in any other native view integration for iOS and Android.
For WebAssembly the Uno Platform has initial support for Skia via the Uno.SkiaSharp.Views package. See details here
This is only a warning that has no effect. If you really want to remove it, add this.
You can add logging using this
Yes, make sure to use the following project definition:
<ItemGroup>
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>
It's in the UWP API, but not implemented yet We have an open Github (issue.)[unoplatform#3]
https://github.com/nventive/Uno/blob/master/doc/articles/supported-features.md
No, but use the (Cross-Platform library template)[https://marketplace.visualstudio.com/items?itemName=nventivecorp.uno-platform-addin] instead to achieve a similar goal.
No, but this sample can serve as a base: https://github.com/nventive/Uno.Prism/tree/uno/Sandbox/Windows10/HelloWorld
If you are using JSON.NET, you need this This file is referenced in the .csproj like that
It is indeed not implemented at the time, see nventive/Uno#4 for now
Is there any particular reason that Uno uses a shared project? and is it possible to use a netstandard project instead?
The view layer needs to be in a shared project because it has native dependencies. For your view models and business logic, it's fine to use a separate netstandard project. Shared projects are also used to work around the fact that Visual Studio is not able to selectively compile a single Target Framework when building a cross-targeted library. Using a shared project improves the build performance when debugging a single platform.
Yes. Here are the templates.
Go to 'Manage NuGet packages for solution...' Find the ReactiveUI package Select all your platform heads (.Wasm, .Android etc) and hit Install
Not yet.
you can specify a custom HTML template like this
This has been fixed starting from Visual Studio 15.9 Preview 3 Please see this Developer Community thread.
Yes, and you can use this (WebAssembly SQLite provider)[https://github.com/nventive/Uno.SQLitePCLRaw.Wasm]
No. You can use Conditional Xaml to work around it: https://github.com/nventive/Uno/blob/master/doc/articles/using-uno-ui.md#supporting-multiple-platforms-in-xaml-files
We've implemented parts of the supported animations, there are others that are still stubbed.
The target API does not affect the min API. You just need to have the API day installed in your android sdk manager. The min sdk is specified in the androidmanifest file.
Is there a workaround for ScrollViewer.ScrollToVerticalOffset method, since it isnt implemented in Uno?
You can use ChangeView instead
Follow the instructions on how to run the WASM head (here)[https://github.com/nventive/Uno.QuickStart#create-an-application-from-the-solution-template]