diff --git a/.gitattributes b/.gitattributes index 90991ebd90c1..e69de29bb2d1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +0,0 @@ -*.md merge=union \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8e7742e73822..c8685c864a91 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ Resource.Designer.cs bld/ [Bb]in/ [Oo]bj/ +logfile=obj/ # Visual Studio 2015 cache/options directory .vs/ diff --git a/Doc/ReleaseNotes/_ReleaseNotes.md b/Doc/ReleaseNotes/_ReleaseNotes.md deleted file mode 100644 index 931b0f0d0ab9..000000000000 --- a/Doc/ReleaseNotes/_ReleaseNotes.md +++ /dev/null @@ -1,11 +0,0 @@ -# Release notes - -## Next version - -### Features - -### Breaking changes - -### Bug fixes - - * 129762 - Updated Android SimpleOrientationSensor calculations based on SensorType.Gravity or based on single angle orientation when the device does not have a Gyroscope. diff --git a/README.md b/README.md index 975df82101b2..0670a0a08b38 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Here's a list of live apps made with the Uno Platform for WebAssembly. * The [Uno.RoslynQuoter](http://roslynquoter-wasm.platform.uno/), a [Roslyn]() based C# analysis tool ([Source](https://github.com/nventive/Uno.RoslynQuoter)) * The [Uno.BikeSharing360 App](http://bikerider-wasm.platform.uno/), a Xamarin.Forms app running on top of Uno for WebAssembly ([Source](https://github.com/nventive/Uno.BikeSharing360_MobileApps)) * The [Uno.WindowsStateTriggers App](http://winstatetriggers-wasm.platform.uno/), a demo of the [Morten's WindowsStateTriggers](https://github.com/dotMorten/WindowsStateTriggers) ([Source](https://github.com/nventive/Uno.WindowsStateTriggers)) +* The [SQLite + Entity Framework Core App](http://sqliteefcore-wasm.platform.uno), a demo of the combination of [Roslyn](https://github.com/dotnet/roslyn), [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/), [SQLite](https://github.com/nventive/Uno.SQLitePCLRaw.Wasm) and the Uno Platform to manipulate an in-browser database. Let us know if you've made your app publicly available, we'll list it here! @@ -54,7 +55,7 @@ Let us know if you've made your app publicly available, we'll list it here! * [State Triggers](https://blogs.msdn.microsoft.com/mvpawardprogram/2017/02/07/state-triggers-uwp-apps/) * [Adaptive Triggers](https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.AdaptiveTrigger) * Platform Specific - * Native controls and properties via [conditional XAML](doc/articles/using-uno-ui.md) + * Native controls and properties via [conditional XAML](doc/articles/using-uno-ui.md#supporting-multiple-platforms-in-xaml-files) * Any of the existing Xamarin iOS/Android libraries available # Getting Started diff --git a/build/Uno.UI.WpfHost.nuspec b/build/Uno.UI.WpfHost.nuspec new file mode 100644 index 000000000000..1d50b9211578 --- /dev/null +++ b/build/Uno.UI.WpfHost.nuspec @@ -0,0 +1,40 @@ + + + + Uno.UI.WpfHost + 2.7.1000 + Uno.UI.WpfHost + nventive + nventive + false + https://github.com/nventive/Uno + https://nv-assets.azurewebsites.net/logos/uno.png + A WPF host for the WebAssembly build on Uno.UI + Copyright (C) 2015-2018 nventive inc. - all rights reserved + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/Uno.UI.nuspec b/build/Uno.UI.nuspec index 4ab20b88bd13..b5885df3ed5e 100644 --- a/build/Uno.UI.nuspec +++ b/build/Uno.UI.nuspec @@ -20,7 +20,7 @@ - + @@ -30,21 +30,21 @@ - + - + - + @@ -109,13 +109,6 @@ - - - - - - - @@ -130,12 +123,6 @@ - - - - - - @@ -150,13 +137,6 @@ - - - - - - - @@ -168,12 +148,6 @@ - - - - - - @@ -186,13 +160,6 @@ - - - - - - - diff --git a/build/Uno.UI.proj b/build/Uno.UI.proj index 033cec70f351..af12e4d8db5b 100644 --- a/build/Uno.UI.proj +++ b/build/Uno.UI.proj @@ -94,9 +94,13 @@ - - - + + + + + @@ -129,20 +133,21 @@ - + + diff --git a/Doc/Assets/layouting-ios.png b/doc/Assets/layouting-ios.png similarity index 100% rename from Doc/Assets/layouting-ios.png rename to doc/Assets/layouting-ios.png diff --git a/Doc/Assets/layouting-ios.pptx b/doc/Assets/layouting-ios.pptx similarity index 100% rename from Doc/Assets/layouting-ios.pptx rename to doc/Assets/layouting-ios.pptx diff --git a/doc/ReleaseNotes/Release-1.40.md b/doc/ReleaseNotes/Release-1.40.md new file mode 100644 index 000000000000..280b1a265940 --- /dev/null +++ b/doc/ReleaseNotes/Release-1.40.md @@ -0,0 +1,175 @@ +# Uno Platform Release 1.40 + +This release is the first non-experimental release of the Uno Platform since the initial public version in May 2018. Lot of bug fixes and features have been added since then, and lots more are coming. + +A lot of those changes where included to support these libraries : [MVVMLight](https://github.com/nventive/uno.mvvmlight), [ReactiveUI](https://github.com/nventive/Uno.ReactiveUI), [Prism](https://github.com/nventive/Uno.Prism), [Rx.NET](https://github.com/nventive/Uno.Rx.NET), [Windows Community Toolkit](https://github.com/nventive/Uno.WindowsCommunityToolkit), [Xamarin.Forms UWP](https://github.com/nventive/Uno.Xamarin.Forms). + +Here are some highlights of this release: + +- General improvement in the memory consumption of the `ListView` control +- Many Wasm rendering and support updates + - Invalid images support + - Text and images measuring fixes + - Add support for AppManifest.displayName +- Support for the `Pivot` control +- Support for inline XAML event handlers in `DataTemplate` +- Support for implicit styles in the `XamlReader` +- Support for `ThreadPoolTimer` +- Add support for implicit `bool` to `Visibility` conversion +- Support for `AutoSuggestBox` +- SourceLink, Reference Assemblies and deterministic builds are enabled +- Support for `x:Name` reference in `x:Bind` markup +- Support for `WriteableBitmap` for all platforms +- Added support for `Cross-platform Library` template in vsix +- Added support for `StaticResource` as top level `ResourceDictionary` element +- Added support for `AutomationPeer` +- Android status bar height is now included in `Window.Bounds` +- Add support for `Underline` in `HyperLinkButton` +- Add support for TextBlock.TextDecorations +- TextBlock base class is now `FrameworkElement` on iOS, instead of `UILabel` +- Auto generated list of views implemented in Uno in the documentation +- Add support for string to `Type` conversion in XAML generator and binding engine +- Support for Attached Properties localization +- Added `ItemsControl.OnItemsChanged` support +- Added support for ListView GroupStyle.HeaderTemplateSelector for iOS/Android + +Here's the full change log: + +- Fixes for VisualTransition.Storyboard lazy bindings [#12](https://github.com/nventive/Uno/pull/12) +- ListView fixes [#22](https://github.com/nventive/Uno/pull/22) + - Improve Path parser compatibility + - Update assets generation documentation + - Fix ItemsWrapGrid layout when ItemHeight/ItemWidth are not set + - Adjust for invalid AnchorPoint support for iOS (#16) + - Fix for ListView initialization order issue +- Default styles clearing fixes [#23](https://github.com/nventive/Uno/pull/23) +- Compatibility and stability fixes [#37](https://github.com/nventive/Uno/pull/37) + - Wasm SplitView fixes + - Enum fast converters + - TextBox InputScope fixes + - Improved ListViewBase stability + - SimpleOrientationSensor fixes + - PathMarkupParser: Add support for whitespace following FillRule command + - Fix DependencyObjectStore.PopCurrentlySettingProperty + - Raised navigation completed after setting CanGoBack/Forward + - Fix layouting that sometimes misapplies margin + - Selector: Coerce SelectedItem to ensure its value is always valid + - Remove legacy panel default constructor restriction + - Wasm image support improvements + - Add support for forward slash in image source + - Add support for CollectionViewSource set directly on ItemsControl.ItemSource + - Fix Pane template binding for SplitView + - Add support for Object as DependencyProperty owner + - Add Wasm support for UIElement.Tapped + - Fix iOS UnregisterDoubleTapped stack overflow +- Compatibility and stability fixes [#43](https://github.com/nventive/Uno/pull/43) + - Adjust WASM thickness support for children arrange + - Fix support for inline text content using ContentProperty + - Fix memory leaks in ScrollViewer + - Adjust for missing styles in UWP Styles FeatureConfiguration + - Fix for Source Generation race condition on slow build servers +- Compatibility and stability fixes [#53](https://github.com/nventive/Uno/pull/53) + - Adjust for WASM Support for local images [#1](https://github.com/nventive/Uno/issues/1) + - Fixes x:Bind support for Wasm + - Fix invalid deserialization of ApplicationDataContainer for iOS + - Fix error for ApplicationView.Title for WASM + - Remove glib conversion errors in WASM +- UWP API Alignments for Wasm [#70](https://github.com/nventive/Uno/pull/70) + - Add support for Application.Start() to provide a proper SynchronizationContext for error management + - Fix for ImplicitStyles support in XamlReader + - Add support for the Pivot control using the default UWP Xaml style + - Adjust body background color after the splash screen removal + - Adjust the materialization of Control templates to not be lazy +- Add support for Xaml file defined event handlers [#71](https://github.com/nventive/Uno/pull/71) +- API Compatibility Updates [#75](https://github.com/nventive/Uno/pull/75) + - Add support for implicit bool to Visibility conversion + - Fix default Style constructor does not set the proper property precedence + - Add more DependencyObjectStore logging + - Align ItemsControl.Items behavior with UWP (#34) + - Fix invalid uri parsing when set through BitmapImage.UriSource +- [WASM] Fix text measure when not connected to DOM [#76](https://github.com/nventive/Uno/pull/76) +- Pivot, AutoSuggestBox, TextBox, XamlReader updates [#77](https://github.com/nventive/Uno/pull/77) + - Added missing TransformGroup ContentProperty + - Fixed invalid namespace attribution of attached properties in XamlReader + - Fixed BitmapImage.UriSource updates not being applied on Wasm + - Add basic implementation of AutoSuggestBox + - Fixed focus stealing issues with inactive PivotItem content + - Add ThreadPoolTimer support + - Fix for iOS popup not appearing + - Fix for Wasm textbox not properly updating while not loaded +- [WASM] Add suport for TextBlock.Padding property [#88](https://github.com/nventive/Uno/pull/88) +- [WASM] Fixed measuring support with Polyfill for Node.isConnected [#89](https://github.com/nventive/Uno/pull/88), [#91](https://github.com/nventive/Uno/pull/91) +- Misc fixes [#93](https://github.com/nventive/Uno/pull/93) + - Fixed iOS `SimpleOrientationSensor` default queue management + - Fixed multiple memory leaks in `ListView`, `ScrollViewer` + - Implemented `CacheLength` for Android `ListViewBase` + - Fixed for `DependencyObject` properties inheritance race condition + - Fix for empty Path reporting an infinite size + - Fix Title not appearing in CommandBar +- Add support for WebAssembly AppManifest.displayName [#94](https://github.com/nventive/Uno/pull/94) +- Enable SourceLink, Reference Assemblies, Deterministic build [#100](https://github.com/nventive/Uno/pull/100) +- Binding Engine Alignments [#113](https://github.com/nventive/Uno/pull/113) + - Use Portable symbols for Xamarin debugging stability + - Enable x:Name reference in x:Bind markup. This requires for a failed BindableMetadata lookup to fall through reflection lookup. + - Assume ".Value" binding path on a primitive is equivalent to self, to enable nullable bindings. + - Adjust unit tests logging + - Enables auto "LogicalChild" treatment to allow for DependencyObjectCollection members to be databound + - Enable parent reset for "LogicalChild" assignations +- Implement the CoreWindow.Dispatcher property [#117](https://github.com/nventive/Uno/pull/117) +- Misc Fixes [#120](https://github.com/nventive/Uno/pull/120) + - Fix for CommandBar back button icon + - Improve HyperLinks hit-testing for iOS + - Fixed android PaintDrawable opacity + - Adjust Unloaded event for ToggleButton + - Adjust for brightness support + - Adjust touch support for rotated elements + - Adjust MinWidth/MinHeight support in Grid + - Adjust PasswordBox custom font for during password reveal + - ListView, ContentControl memory improvements + - Style behavior adjustements +- Update for android animation reliability [#123](https://github.com/nventive/Uno/pull/123) +- Add support for WriteableBitmap [#125](https://github.com/nventive/Uno/pull/125) +- Updated vsix structure [#128](https://github.com/nventive/Uno/pull/128) +- Multiple enhancements for WCT 4.0 [#131](https://github.com/nventive/Uno/pull/131) + - Adds support for `IconElement` fast conversion + - Adds stubs for `ToggleSwitchTemplateSettings`, `PackageId`, `UISettings` + - Adjust `XamlObjectBuilder` logging + - Add implicit conversion for `KeyTime` and `Duration` + - Add support for top level `StaticResource` resource dictionary elements + - Implement FindFirstParent for net46/netstd2.0 + - Adds ElementNotAvailableException and ElementNotEnabledException + - Fix invalid measure for empty wasm images + - Add size/rect checks for measure/arrange wasm + - Improve XamlReader error reporting +- Add support for Cross-platform library template in VSIX [#132](https://github.com/nventive/Uno/pull/132) +- Add support for AutomationPeer [#141](https://github.com/nventive/Uno/pull/141) +- Improved support for UWP resources [#149](https://github.com/nventive/Uno/pull/149) + - Projects no longer need to define `XamlCodeGenerationFiles` (fixes #144) + - Projects no longer need to define `ResourcesDirectory` (fixes #106) + - Projects no longer need to initialize `ResourceHelper.ResourcesService` (fixes #142) + - `ResourceLoader.GetString` is now supported (fixes #142) +- Updates rollup [#151](https://github.com/nventive/Uno/pull/151) + - Fixed `VisualState` not updated when `TextBox` is focused + - Improve `ListView` and `Selector` memory footprint + - Adjust GenericStyles application sequence for Android + - Add diagnostics methods for `BinderReferenceHolder` + - Include android status bar height in `Window.Bounds` + - Fixed `Grid` items size when `MinHeight` and `MinHeight` are used + - Fixed android race condition during visual tree cleanup + - Add support for underline in `HyperLinkButton` + - Fixed `ScrollContentPresenter` margin issue + - Adjust `MessageDialog` behavior for android + - `ContentControl` Data Context is now properly unset + - Add `EmailNameOrAddress` InputScope for `TextBox` + - Fixed duplicated resw entry support + - Fixed `ComboBox` popup touch issue + - Add support for TextBlock.TextDecorations + - TextBlock base class from UILabel to FrameworkElement +- Auto-generate list of views implemented in Uno [#152](https://github.com/nventive/Uno/pull/152) +- Add support for string to `Type` conversion in Xaml generator and Binding engine. [#159](https://github.com/nventive/Uno/pull/159) +- Add support for attached properties localization [#156](https://github.com/nventive/Uno/pull/156) +- Added `ItemsControl.OnItemsChanged` support [#175](https://github.com/nventive/Uno/pull/175) +- Added support for XAML inline collections declaration [#184](https://github.com/nventive/Uno/pull/184) +- Adjust the sequence of control template materialization [#192](https://github.com/nventive/Uno/pull/192) +- Support for ListView.ScrollIntoView with leading alignment +- Added support for ListView GroupStyle.HeaderTemplateSelector \ No newline at end of file diff --git a/doc/ReleaseNotes/U2.md b/doc/ReleaseNotes/U2.md deleted file mode 100644 index 90d0263b9cc9..000000000000 --- a/doc/ReleaseNotes/U2.md +++ /dev/null @@ -1,13 +0,0 @@ -## Uno Release U2 - -### Features - - * Implements `ListViewBase.ScrollIntoView(position, ScrollIntoViewAlignment.Leading)` on **Android**. - -### Breaking changes - - * - -### Bugfixes - - * \ No newline at end of file diff --git a/doc/ReleaseNotes/U3.md b/doc/ReleaseNotes/U3.md deleted file mode 100644 index 8ec8b5109f1b..000000000000 --- a/doc/ReleaseNotes/U3.md +++ /dev/null @@ -1,17 +0,0 @@ -## Uno Release U2 - -### Features - - -### Breaking changes - - * - -### Bugfixes - - * #116111 Fixed the Xaml parsing on macOS not taking into account escaping accolades - * #116876 [Android] ItemsWrapGrid now correctly handles items with Stretch dimensions - * Fixes a bug where two `UIDatePickers` (e.g. `DatePickerSelector` and `TimePickerSelector`) would interefer one with the other if they had different time zones. - * Fixes a bug where the `CommandBar.Content` will not have a `DataContext`. - * #116196 Fixed the selection in ListViewBase to reset when the items list becomes null. - * #116875 [iOS] [Button] Button with ContentPresenter does not trim appropriately \ No newline at end of file diff --git a/doc/ReleaseNotes/_ReleaseNotes.md b/doc/ReleaseNotes/_ReleaseNotes.md new file mode 100644 index 000000000000..d6e972924e23 --- /dev/null +++ b/doc/ReleaseNotes/_ReleaseNotes.md @@ -0,0 +1,39 @@ +# Release notes + +## Next version + +### Features +* + +### Breaking changes +* + +### Bug fixes +* + +## Release 1.41 + +### Features + +* [#154](https://github.com/nventive/Uno/issues/154) Implement the MediaPlayerElement control +* 135799 Implemented MediaPlayer.Dispose() + +### Bug fixes + + * 129762 - Updated Android SimpleOrientationSensor calculations based on SensorType.Gravity or based on single angle orientation when the device does not have a Gyroscope. + * 134189 [iOS] The Time Picker flyout placement is not always respected + * 134132 [Android] Fix loading of ItemsPresenter + * 134104 [iOS] Fixed an issue when back swiping from a page with a collapsed CommandBar + * 134026 [iOS] Setting a different DP from TextBox.TextChanging can cause an infinite 'ping pong' of changing Text values + * 134415 [iOS] MenuFlyout was not loaded correctly, causing templates containing a MenuFlyout to fail + * 133247 [iOS] Image performance improvements + * 135192 [iOS] Fixed ImageBrush flash/flickering occurs when transitioning to a new page. + * 135112 [Android] Fix crash in UpdateItemsPanelRoot() in the ItemsControl class. + * 132014, 134103 [Android] Set the leading edge considering header can push groups out off the screen + * 131998 [Android] Window bounds set too late + * 131768 [iOS] Improve ListView.ScrollIntoView() when ItemTemplateSelector is set + * 135202, 131884 [Android] Content occasionally fails to show because binding throws an exception + * 135646 [Android] Binding MediaPlayerElement.Source causes video to go blank + * 136093, 136172 [iOS] ComboBox does not display its Popup + * 134819, 134828 [iOS] Ensures the back gesture is enabled and disabled properly when the CommandBar is visible, collapsed, visible with a navigation command and collapsed with a navigation command. + * 136092 [iOS] ScrollIntoView() throws exception for ungrouped lists \ No newline at end of file diff --git a/Doc/Uno-UI-Layouting-iOS.md b/doc/Uno-UI-Layouting-iOS.md similarity index 100% rename from Doc/Uno-UI-Layouting-iOS.md rename to doc/Uno-UI-Layouting-iOS.md diff --git a/doc/articles/MediaPlayerElement.md b/doc/articles/MediaPlayerElement.md new file mode 100644 index 000000000000..f565b26dc308 --- /dev/null +++ b/doc/articles/MediaPlayerElement.md @@ -0,0 +1,91 @@ +# MediaPlayerElement + +See [MediaPlayerElement](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.mediaplayerelement) on MSDN + +## Media formats + +| Supported Formats | iOS | Android | Remarks | +|-------------------------------------------------------|-------|-----------|-----------------------------------| +| Local/Remote MP3 Support | X | X | | +| Local/Remote MPEG4 Support | X | X | | +| HLSv3 Support | X | X | | +| HLSv4 Support | X | X | | +| MPEG-Dash Support | - | - | | +| Smooth Streaming Support | - | - | | + +_If you need to set source programmatically (ie, using `_mediaPlayerElement.Source = [source]`), please note that only source created with `MediaSource.CreateFromUri()` are currently supported_ + +## Features + +| Section | Feature | iOS | Android | Remarks | +|-----------------------|-------------------------------------------------------|-------|-----------|-----------------------------------------------| +| MediaPlayerElement | AutoPlay | X | X | | +| | Poster image | X | X | Does not show when playing music | +| | Enable/Disable MediaTransportControls | X | X | | +| | Stretch | X | X | Stretch.None behave like Stretch.Fill on iOS | +| | Pause media when headphones unplugged | X | X | | +| TransportControls | Transport controls custom style | X | X | | +| | Play/Pause | X | X | | +| | Stop | X | X | | +| | Seek | X | X | | +| | Volume change | X | X | | +| | Mute | X | X | | +| | Show elapsed time | X | X | | +| | Show remaining time | X | X | | +| | Show/Hide MediaTransportControls automatically | X | X | | +| | MediaTransportControls compact mode | X | X | | +| | Show/Hide MediaTransportControls commands | X | X | | +| | Enable/Disable MediaTransportControls commands | X | X | | +| | Skip forwoard | X | X | | +| | Skip backward | X | X | | +| | Show buffering progress | X | X | | +| | Zoom mode | X | X | | +| | Fullscreen mode | - | - | | +| | Change playback rate | - | - | | +| | Player controls on locked screen support | - | - | | +| | Playlists support | - | - | | +| | Subtitles support | - | - | | +| | Languages support | - | - | | + +## Requirement + +### iOS + +Add the folowwing to your info.plist + +```xml +NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSExceptionMinimumTLSVersion + TLSv1.2 + +``` + +__Note:__ Don't just copy/paste, but properly setup `NSAppTransportSecurity` as required by your project + +### Android + +Add the folowwing to your AndroidManifest.xml + +```xml + + + + +``` + +## Future improvement + +- Playback rate support +- React to audio focus changes (pause/stop playback or reduce audio volume) +- Subtitles support +- Languages support +- Display poster for audio media + +## Known issues + +- Volume flyout does not display on iOS (Uno issue) +- Dynamic width/height not supported when playing audio +- Sometimes flickers during resizing when using dynamic width/height \ No newline at end of file diff --git a/doc/articles/Uno.UI.Toolkit.md b/doc/articles/Uno.UI.Toolkit.md new file mode 100644 index 000000000000..57675cee46aa --- /dev/null +++ b/doc/articles/Uno.UI.Toolkit.md @@ -0,0 +1,39 @@ +# Uno.UI.Tollkit + +Uno.UI.Tollkit is a set of extension methods or behaviors used to enhance UWP and activate device/OS specific features. + +Those methods are built to have no effect on platform that does not support the enhanced feature: no need to wrap them into conditional code. + +## MenuFlyoutItem - Destructive style + +iOS can display `MenuFlyoutItem` to warn user the action will be "destructive". In that case, the button text is display in red. + +To set a `MenuFlyoutItem` as destructive, add the toolkit namespace to your XAML + +```xml +xmlns:toolkit="using:Uno.UI.Toolkit" +``` + +And declare your `MenuFlyoutItem` as follow + +```xml + +``` + +## UICommand - Destructive style + +iOS can display `UICommand` to warn user the action will be "destructive". In that case, the button text is display in red. + +To set a `UICommand` as destructive, add the toolkit namespace to your code + +```csharp +using Uno.UI.Toolkit; +``` + +And declare your `UICommand` as follow + +```csharp +var uic = new UICommand("Destructive action"); +uic.SetDestructive(true); +``` \ No newline at end of file diff --git a/doc/articles/faq.md b/doc/articles/faq.md index 13e47c14217b..56e3010c2687 100644 --- a/doc/articles/faq.md +++ b/doc/articles/faq.md @@ -286,3 +286,87 @@ Yes, make sure to use the following project definition: ``` + +## Does Uno offer a TreeView control? + +It's in the UWP API, but [not implemented yet](https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/tree-view) +We have an open Github (issue.)[https://github.com/nventive/Uno/issues/3] + +## Is there a table of all UWP controls and their features compared to what's offered under Uno? + +https://github.com/nventive/Uno/blob/master/doc/articles/supported-features.md + +## Is there an Uno template that is based on portable class library? + +No, but use the (Cross-Platform library template)[https://marketplace.visualstudio.com/items?itemName=nventivecorp.uno-platform-addin] instead to achieve a similar goal. + +## Is there a Visual Studio template for Uno that incorporates the Prism library? + +No, but this sample can serve as a base: https://github.com/nventive/Uno.Prism/tree/uno/Sandbox/Windows10/HelloWorld + +## I get errors when serializing Json in Uno Wasm + +If you are using JSON.NET, you need [this](https://github.com/nventive/Uno.Playground/blob/master/src/Uno.Playground.WASM/LinkerConfig.xml) +This file is referenced in the .csproj like [that](https://github.com/nventive/Uno.Playground/blob/master/src/Uno.Playground.WASM/Uno.Playground.WASM.csproj#L43) + +## Is NavigationView supported in Uno? + +It is indeed not implemented at the time, see [nventive/Uno#4](https://github.com/nventive/Uno/issues/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. + +## Are there any Visual Studio project creation templates for Uno yet? + +Yes. Here are the [templates].(https://marketplace.visualstudio.com/items?itemName=nventivecorp.uno-platform-addin) + +## How do I add the NuGet package if there's no Packages node for Shared Projects? + +Go to 'Manage NuGet packages for solution...' +Find the ReactiveUI package +Select all your platform heads (.Wasm, .Android etc) and hit Install + +## Is RichEditBox supported in Uno.Platform? + +Not yet. + +## Is there a way to use local css/js libraries and not those on a CDN? + +you can specify a custom HTML template like [this](https://github.com/nventive/Uno.Wasm.Bootstrap#indexhtml-content-override) + +## Debugging a published nuget package breaks the Xamarin iOS and Android debugger + +This has been fixed starting from Visual Studio 15.9 Preview 3 +Please see this [Developer Community thread.](https://developercommunity.visualstudio.com/content/problem/306764/debugging-a-published-nuget-package-break-the-xama.html) + +## Does Uno offer an `AutoSuggestBox`? + +[Yes](https://github.com/nventive/Uno/blob/master/src/Uno.UI/UI/Xaml/Controls/AutoSuggestBox/AutoSuggestBox.cs) + +## Is there a database that works on all platforms? + +Yes, and you can use this (WebAssembly SQLite provider)[https://github.com/nventive/Uno.SQLitePCLRaw.Wasm] + +## Are Popups/RichEditbox implemented in Uno? + +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 + +## Does Uno support all UWP animations? + +We've implemented parts of the supported animations, there are others that are still stubbed. + +## Visual Studio is requiring Android API v26 but I want to test on an older device. + +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 + +## I am having issues running a Wasm project head + +Follow the instructions on how to run the WASM head (here)[https://github.com/nventive/Uno.QuickStart#create-an-application-from-the-solution-template] \ No newline at end of file diff --git a/doc/articles/map-control-support.md b/doc/articles/map-control-support.md new file mode 100644 index 000000000000..f9598c09eb9c --- /dev/null +++ b/doc/articles/map-control-support.md @@ -0,0 +1,121 @@ +# MapControl + +The `MapControl` is a control which allows you to display maps in your app. + +## Architecture + +To be able to support multiple map providers, the map control is rendering its content in a `MapPresenter` control in the `Uno.UI.Maps` Nuget package. This separation is also required to avoid +pulling dependencies in an application that does not need Maps. + +The current implementation is using the native UIKit map for iOS, and the Google Play Services map control. + +## Sample Xaml + +See a more complete sample here: + +```xml + + + + + + + + + + + + + + +``` + +## Platform support + +| Feature | Android | iOS | Wasm | +| ------------------------------------------|:-------:|:---:|:----:| +| Display a map | X | X | | +| Display a path | | X | | +| Customize pushpins with icon | | | | +| Fully template pushpins | | | | +| Show user's location on map | | | | +| Toggle native Locate-Me button visibility | | | | +| Toggle native Compass button visibility | | | | + +## Usage + +### 1. Configure your application. + +- For **Android**, + 1. Add the following to AndroidManifest.xml + ```xml + + ``` + 2. Generate the API key and/or inform your client how to generate it. + 1. Go to https://console.developers.google.com + 2. Login with a Google account + 3. Go to the Credentials section to the top left + 4. Click on "Create credentials", then "API key" + 5. Go to the Dashboard section in the left-hand side menu + 6. Click on the relevant service - for instance, "Google Maps Android API" and click on Enable + + 3. Add the API key to `AssemblyInfo.cs`, this should vary depending on the platform and environment, therefore should be retrieved from ClientConstants: + ```csharp + [assembly: MetaData("com.google.android.maps.v2.API_KEY", Value = ClientConstants.Maps.GoogleMapApiKey)] + ``` + + 4. Add the relevant permissions, if you wish to access the location of the user (either coarse or fine location): + ```csharp + //[assembly: UsesPermission(Android.Manifest.Permission.AccessCoarseLocation)] + [assembly: UsesPermission(Android.Manifest.Permission.AccessFineLocation)] + + [assembly: UsesPermission("com.myapp.permission.MAPS_RECEIVE")] + [assembly: Permission(Name = "com.myapp.permission.MAPS_RECEIVE", ProtectionLevel = Android.Content.PM.Protection.Signature)] + ``` + + +# Get API key for map component + +In order to use the map component, you will need an API key for Windows and Android. Here are the steps to retrieve it. + +## Windows + +_For the detailed procedure for Windows, please follow this link: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/mt219694.aspx _ + ++ Go to https://www.bingmapsportal.com ++ Login to your account or register if you don't have one ++ Go to MyAccount -> Keys ++ Enter the following information: + - Application name + - Application URL (optional) + - Key type + - Application type ++ Enter the characters you see in the box ++ Hit *Create* and get the key + +The key should be added as the value for the parameter _MapServiceToken_ for the MapControl object. + +## Android + +_For the detailed procedure on Android, please follow this link: https://developers.google.com/maps/documentation/android-api/signup#release-cert _ + ++ Retrieve the application's SHA-1 fingerprint ++ Create a project in the Google Developers Console ++ Go to Credentials -> Add credentials -> API key -> Android key ++ In the dialog box, enter the SHA-1 fingerprint and the app package name ++ Hit *Create* and get the key + +The API key should be the value for the property _com.google.android.maps.v2.API_KEY_ in the AndroidManifest.xml file. \ No newline at end of file diff --git a/doc/articles/supported-features.md b/doc/articles/supported-features.md index 1fc779d7801c..e462d346c34a 100644 --- a/doc/articles/supported-features.md +++ b/doc/articles/supported-features.md @@ -145,3 +145,4 @@ - UI Priority dispatch - Windows.Graphics.Display.DisplayInformation orientation - Windows.Media.SpeechRecognition +- Windows.Media.Capture.CameraCaptureUI \ No newline at end of file diff --git a/doc/articles/toc.yml b/doc/articles/toc.yml index 58c803415952..52d8a4f565b2 100644 --- a/doc/articles/toc.yml +++ b/doc/articles/toc.yml @@ -16,3 +16,7 @@ href: debugging-uno-ui.md - name: Feature Flags href: feature-flags.md +- name: Speech Recognition + href: SpeechRecognition.md +- name: Media Player + href: MediaPlayerElement.md diff --git a/doc/articles/using-uno-ui.md b/doc/articles/using-uno-ui.md index 744d562c6d8e..bc60e6ca33e2 100644 --- a/doc/articles/using-uno-ui.md +++ b/doc/articles/using-uno-ui.md @@ -294,6 +294,14 @@ Uno.UI also generates a nested class named StaticResources in all non-ResourceDi Uno.UI supports the [authoring of styles](https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.style.aspx). +## Localization + +Localization is done through the `resw` files in the current project. Resources are then used using `x:Uid`. + +See [Localize strings in your UI](https://docs.microsoft.com/en-us/windows/uwp/app-resources/localize-strings-ui-manifest). + +Note that the default language can be defined using the `DefaultLanguage` property, using an IETF Language Tag (e.g. `en` or `fr-FR`). + ## Supported Uno.UI Controls ### Grid diff --git a/doc/articles/working-with-commandbar.md b/doc/articles/working-with-commandbar.md index b1bb0f5f41fe..bf7798e059ab 100644 --- a/doc/articles/working-with-commandbar.md +++ b/doc/articles/working-with-commandbar.md @@ -269,7 +269,10 @@ Unlike the `PrimaryCommands` or `SecondaryCommands`, which appear to the right o This is typically used for burger menus. -Setting `NavigationCommand` on pages with a back button will replace it (and disable the back gesture on **iOS**). +On **iOS**, the back gesture can be enabled or disabled using this property. + +- When a `CommandBar` (visible or collapsed) is in the visual tree, the back gesture is **enabled**. +- When a `CommandBar` has a `NavigationCommand`, the back gesture is **disabled**. On **Android**, only icons are supported (`AppBarButton.Icon`). This is due to a platform limitation, which can be explained by the fact that `CommandBar.Content` is left-aligned. @@ -295,6 +298,12 @@ To ensure everything works properly, you must follow a few rules: * The `CommandBar` must be accessible as soon as the page is being navigated to (i.e., don't put it inside a `DataTemplate` or an `AsyncValuePresenter`). * There can only be one `CommandBar` per page. +## Extensibility + +The `CommandBar` it automatically managed by the `Frame` control, however you can still use the "native" mode of the `CommandBar` with your own navigation mechanisim. + +On **iOS** a `CommandBarHelper` is available for this purpose, you only have to invoke each of the provided method in your own `UIViewController` implementation. + # AppBarButton The `AppBarButton` in **Uno** is designed to be used the same way you would use the `AppBarButton` on **UWP**. In most cases, you should refer to the [official `CommandBar` documentation](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.appbarbutton). @@ -875,4 +884,4 @@ Can’t superpose views over a CommandBar. Can’t animate/translate the CommandBar (i.e., when hiding/showing it based on scroll offset). Can’t put your CommandBar inside a ScrollViewer and make it scroll. Can’t put your CommandBar inside templates (i.e., AVP). -Can’t cancel a back navigation using BackRequestedEventArgs.Handled. \ No newline at end of file +Can’t cancel a back navigation using BackRequestedEventArgs.Handled. diff --git a/doc/articles/working-with-uno-wpf-host.md b/doc/articles/working-with-uno-wpf-host.md new file mode 100644 index 000000000000..f2048e93464f --- /dev/null +++ b/doc/articles/working-with-uno-wpf-host.md @@ -0,0 +1,38 @@ +# The Uno.UI WebAssembly WPF Host + +The Uno Platform provides the ability to run UWP and .NET code through the Mono runtime. While WebAssembly makes it very easy to deploy on the Web, it currently is, as of October 2018, not very easy to debug a application running in this context. + +In order to ease the debugging of such an application, the Uno Platform provides the [Uno.UI.WpfHost package](https://www.nuget.org/packages/Uno.UI.WpfHost) to allow running the Uno Platform inside of a WPF application, using a Chromium WebView. + +This mode is possible by replacing the WebAssembly runtime by the Desktop .NET Framework, and have it communicate with the WebView via Javascript `eval()` calls on the WebView control. This enables easier troubleshooting of the .NET code, as all the C# code is running in a VisualStudio supported scenario, where C# edit and continue and all the debugger features are available. + +## Using the Uno.UI.WpfHost package + +- Create an Uno Platform app using the [Visual Studio extension](https://marketplace.visualstudio.com/items?itemName=nventivecorp.uno-platform-addin#overview) named `MyApp` +- Add a WPF application head +- Reference the [Uno.UI.WpfHost package](https://www.nuget.org/packages/Uno.UI.WpfHost) +- In the new WPF head, reference the `MyApp.Wasm` project +- The constructor of the MainWindow, add the following code: +```csharp +UnoHostView.Init(() => MyApp.Wasm.Program.Main(new string[0]), $@"..\..\..\..\MyApp.Wasm\bin\{configuration}\netstandard2.0\dist"); +``` + +- In the `MainWindow.xaml` file: + +```xml + + + + + +``` + +Running the application will then execute the Wasm head code inside of the WPF application, allowing for the debugging of the C# code. \ No newline at end of file diff --git a/doc/blog/201809-UnoUnderTheHoodDependencyObjectGeneration.md b/doc/blog/201809-UnoUnderTheHoodDependencyObjectGeneration.md new file mode 100644 index 000000000000..afb538a191ce --- /dev/null +++ b/doc/blog/201809-UnoUnderTheHoodDependencyObjectGeneration.md @@ -0,0 +1,154 @@ +# Talkin' 'bout my generation: How the Uno Platform generates code, part 2 + +[Previously](https://medium.com/@unoplatform/talkin-bout-my-generation-how-the-uno-platform-generates-code-part-1-under-the-hood-7664d83c4f90) we looked at how the [Uno Platform](https://platform.uno/) turns XAML mark-up files into C# code. In this article, I'll talk about another way Uno uses code generation, allowing us to make native Android and iOS views conform to UWP's API, and tackle the thorny problem of [multiple inheritance](https://en.wikipedia.org/wiki/Multiple_inheritance). + +## Wanting it all +Part of the power of Uno on Android and iOS is the ability to easily mix UWP view types with purely native views. This is possible because, in Uno, all views inherit from the native base view type: [View](https://developer.android.com/reference/android/view/View) on Android, [UIView](https://developer.apple.com/documentation/uikit/uiview) on iOS. + + + +But as I alluded to in an earlier article, this poses a challenge for reproducing UWP's inheritance hierarchy. UIElement is the primitive view type in UWP, but it in turn derives from the DependencyObject class. `DependencyObject` is the base class for anything that has `DependencyProperties`, that is, anything that supports databinding. That includes all views, as well as some non-view framework types like [Transforms](https://docs.microsoft.com/en-us/windows/uwp/design/layout/transforms) and [Brushes](https://docs.microsoft.com/en-us/windows/uwp/design/style/brushes). + + + +We want to inherit from `ViewGroup` or `UIView`. We also want to inherit from `DependencyObject.` C# doesn't permit multiple inheritance, so what do we do? Since we can't change the iOS or Android frameworks, we opted instead within Uno to make `DependencyObject` an [interface](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/interfaces/index). That allows an Uno `FrameworkElement` to be a `UIView` and at the same time to be a `DependencyObject`. But that alone isn't enough. + + +What if you have code like this in your app? + +```` csharp + public class MyBindableObject : DependencyObject + + { + + public string MyProperty + + { + + get { return (string)GetValue(MyPropertyProperty); } + + set { SetValue(MyPropertyProperty, value); } + + } + + + + // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... + + public static readonly DependencyProperty MyPropertyProperty = + + DependencyProperty.Register("MyProperty", typeof(string), typeof(MyBindableObject), new PropertyMetadata(default(string))); + + } +```` + + +We're inheriting from `DependencyObject` and defining a `DependencyProperty` using the standard syntax, which uses the `DependencyObject.GetValue` and `DependencyObject.SetValue` methods. On UWP these are defined in the base class, but if `DependencyObject` is an interface then there _is_ no base class. In fact if it's just an interface then the code won't compile, because the interface hasn't been implemented. + +Luckily `DependencyObject` isn't _just_ an interface in Uno, and the code above will compile as-is on Android and iOS, just as it does on UWP. Code generation makes it happen. Here's some programmer art to illustrate the point. The detailed explanation is below. + +![UWP inheritance](Assets/DependencyObjectGeneration/DependencyObjectGenerator_UWP.png) +*On UWP, `UIElement` inherits from the `DependencyObject` class.* +![Multiple inheritance](Assets/DependencyObjectGeneration/DependencyObjectGenerator_nope.png) +*Multiple inheritance - not an option.* +![Multiple inheritance](Assets/DependencyObjectGeneration/DependencyObjectGenerator_Uno.png) +*In Uno, `DependencyObject` is an interface, with the implementation automagically supplied by code generation.* + +We face a weaker form of this problem - wanting to have two base types - in other cases is well. In a few places in the framework we inherit from a more derived native view type. For example, `ScrollContentPresenter` inherits from the native scroll view on Android and iOS. But we also want `ScrollContentPresenter` to expose the methods and properties of `FrameworkElement`. + +We successfully addressed both of these problems by using code generation to implement mixins in C#. + +## Mixing things up +Most statically-typed languages don't permit multiple base classes on account of the added complexity it brings, a.k.a. the ['diamond problem'](https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem). (C++ is a notable exception.) In dynamically-typed languages, however, it's quite common to bolt on extra functionality to a class in a reusable way with [mixins](https://en.wikipedia.org/wiki/Mixin). + +C#, as a statically-typed language, doesn't support mixins as a first-class language feature. Code generation allows us to simulate it, though. Uno uses code generation to add mixins in (at least) two different ways. + +I'll start with the simpler approach: using 'T4' templates. To quote Microsoft's documentation: +> In Visual Studio, a T4 text template is a mixture of text blocks and control logic that can generate a text file. The control logic is written as fragments of program code in Visual C# or Visual Basic. In Visual Studio 2015 Update 2 and later, you can use C# version 6.0 features in T4 templates directives. The generated file can be text of any kind, such as a web page, or a resource file, or program source code in any language. + +*Source:* https://docs.microsoft.com/en-us/visualstudio/modeling/code-generation-and-t4-text-templates?view=vs-2017 + +T4 templates ('.tt files') have been around for quite a while. They're essentially a mix of static text (which is C# code, in our case) and conditional logic. Here's a snippet: + +```` csharp +namespace <#= mixin.NamespaceName #> +{ + public partial class <#= mixin.ClassName #> : IFrameworkElement + { + #if !<#= mixin.IsFrameworkElement #> + /// + /// Gets the parent of this FrameworkElement in the object tree. + /// + public DependencyObject Parent => ((IDependencyObjectStoreProvider)this).Store.Parent as DependencyObject; +#endif + +#if <#= mixin.HasAttachedToWindow #> + partial void OnAttachedToWindowPartial() + { + OnLoading(); + OnLoaded(); + } +� +```` + +That's from the [template](https://github.com/nventive/Uno/blob/be4f4e938a861d5802c228efc314c1f3ea314027/src/Uno.UI/UI/Xaml/IFrameworkElementImplementation.iOS.tt#L30-L46) which adds `IFrameworkElement` functionality in Uno. It implements properties like `Width`/`Height`, `Opacity`, `Style`, etc. At compile time, the template runs and creates a [partial class](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/partial-classes-and-methods) with those members for `ScrollContentPresenter` and several other classes (including `FrameworkElement` itself). + +The T4 approach is well-tested and works well in this scenario. It has a couple of limitations though: + +1. It requires manual set-up: each class that wants to use the mixin has to be explicitly registered. +2. It requires manual flags to make sure that the generated code doesn't 'step on' the authored code, eg by generating a `Foo()` method when the authored code already defines `Foo()`. +3. It doesn't support external code. You can't use the mixin above in your app (short of copy-pasting the templates into the app). + +For that reason, in order to have a mixin to implement `DependencyObject`'s features, we went with something a little more complex and a little more magical. + +## DependencyObjectGenerator - Making the magic happen +The release of [Roslyn](https://github.com/dotnet/roslyn), aka the '.NET Compiler Platform', was a boon to code generation. With Roslyn, Microsoft open-sourced the C# compiler, but they also exposed a powerful API for code analysis. With Roslyn it's easy to access all the syntactic and semantic information that the compiler possesses. + +To leverage this power for code generation, we created the [Uno.SourceGeneration](https://github.com/nventive/Uno.SourceGeneration) package. Like the Uno Platform, it's free and open source. It creates a build task and allows you to easily add generated code based on Roslyn's analysis of your solution. This might be partial class definitions which augment existing types, or it might be entirely new classes. + +In Uno, this used by the [DependencyObjectGenerator](https://github.com/nventive/Uno/blob/master/src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.cs) class. This generator looks for every class in the solution that implements the `DependencyObject` interface, like our `MyBindableObject` example above. For each such class, it automatically generates the methods and properties of `DependencyObject`. + +Since the generator has a full set of semantic information from Roslyn, it can do this in a smart way. For instance, if it detects that the class is a view type, it adds methods to update binding information when the view is loaded or unloaded. + +Here's a [small snippet](https://github.com/nventive/Uno/blob/74ba91756c446107e7394e0423527de273154f5d/src/SourceGenerators/Uno.UI.SourceGenerators/DependencyObject/DependencyObjectGenerator.cs#L218-L250) of code from `DependencyObjectGenerator`: + +```` csharp + private void WriteAndroidAttachedToWindow(INamedTypeSymbol typeSymbol, IndentedStringBuilder builder) + { + var isAndroidView = typeSymbol.Is(_androidViewSymbol); + var isAndroidActivity = typeSymbol.Is(_androidActivitySymbol); + var isAndroidFragment = typeSymbol.Is(_androidFragmentSymbol); + var isUnoViewGroup = typeSymbol.Is(_unoViewgroupSymbol); + var implementsIFrameworkElement = typeSymbol.Interfaces.Any(t => t == _iFrameworkElementSymbol); + var hasOverridesAttachedToWindowAndroid = isAndroidView && + typeSymbol + .GetMethods() + .Where(m => IsNotDependencyObjectGeneratorSourceFile(m)) + .None(m => m.Name == "OnAttachedToWindow"); + + if (isAndroidView || isAndroidActivity || isAndroidFragment) + { + if (!isAndroidActivity && !isAndroidFragment) + { + WriteRegisterLoadActions(typeSymbol, builder); + } + + builder.AppendLine($@" +#if {hasOverridesAttachedToWindowAndroid} //Is Android view (that doesn't already override OnAttachedToWindow) +#if {isUnoViewGroup} //Is UnoViewGroup + // Both methods below are implementation of abstract methods + // which are called from onAttachedToWindow in Java. + protected override void OnNativeLoaded() + {{ + _loadActions.ForEach(a => a.Item1()); + BinderAttachedToWindow(); + }} +```` + +In this method we have an [INamedTypeSymbol](https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.inamedtypesymbol?view=roslyn-dotnet), an object from Roslyn that encapsulates information about a type. We've already determined that `typeSymbol` implements `DependencyObject`; here we check if it's an Android `View` and, if so override the loaded method. You can notice that we're also checking that the type doesn't _already_ override the same method, so we don't accidentally generate code that clashes with authored code and causes a compiler error. All this goes on under the hood without user intervention, whenever your app compiles. + +The end result is that `DependencyObject` can be used almost exactly the same way with Uno as with UWP, even though it's an interface and not a class! There are edge cases: some generic constraints won't work the same way, for example. But in general it works remarkably well. + + --- + +That's all for now. Let us know what other 'under the hood' aspects of Uno you'd like to hear more about! diff --git a/doc/blog/201809-UnoUnderTheHoodXamlGeneration.md b/doc/blog/201809-UnoUnderTheHoodXamlGeneration.md new file mode 100644 index 000000000000..bffd90766ea3 --- /dev/null +++ b/doc/blog/201809-UnoUnderTheHoodXamlGeneration.md @@ -0,0 +1,85 @@ +# Talkin' 'bout my generation: How the Uno Platform generates code, part 1 + +In [previous](https://medium.com/@unoplatform/under-the-hood-an-introduction-to-uno-platform-6064a765d6a) [articles](https://hackernoon.com/pushing-the-right-buttons-how-uno-implements-views-under-the-hood-a5e93ea86688) we've covered how the [Uno Platform](https://platform.uno/) takes a visual tree defined in the [XAML](https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/xaml-overview) markup language and creates it on iOS, Android, and WebAssembly. In this article I want to dive into a key intermediate step: how the XAML is parsed and mapped to generated C# code. In an upcoming part 2, we'll look at a few other ways in which Uno leverages code generation to make the wheels turn. + +## Parsing XAML + +XAML stands for eXtensible Application Markup Language. It's an XML-based syntax. Although it can be used to describe [pretty much anything](https://docs.microsoft.com/en-us/dotnet/framework/windows-workflow-foundation/serializing-workflows-and-activities-to-and-from-xaml), it's geared toward describing the structure of an application. It was first used in [Windows Presentation Foundation](https://en.wikipedia.org/wiki/Windows_Presentation_Foundation), and since then has been used (with minor syntactic differences) in a number of contexts, including Silverlight (RIP), WinRT, Xamarin Forms, and the Universal Windows Platform. + +XAML hits a sweet spot: it's human readable, expressive, and sufficiently structured to support design tools like [Blend](https://docs.microsoft.com/en-us/visualstudio/designers/creating-a-ui-by-using-blend-for-visual-studio?view=vs-2017) and [XAML Designer](https://docs.microsoft.com/en-us/visualstudio/designers/creating-a-ui-by-using-xaml-designer-in-visual-studio?view=vs-2017). One nice feature is that it can be seamlessly intermingled with C# via [code-behind](https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/code-behind-and-xaml-in-wpf) files. + +To tap into that power, Uno needs to be able to read a XAML file and convert it into compileable C# code. + +The first step is to parse the file into a Xaml object tree, using the [System.Xaml](https://docs.microsoft.com/en-us/dotnet/api/system.xaml?view=netframework-4.7.2) namespace. Next, the Xaml object tree is processed into a C# class definition. The bulk of the heavy lifting is done in the mammoth [XamlFileGenerator](https://github.com/nventive/Uno/blob/master/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs) class. We lean on the [Microsoft.CodeAnalysis API](https://github.com/dotnet/roslyn) here (aka 'Roslyn') to match types used in XAML to types defined in the app assembly or its dependencies. The output is saved to a generated file. + +All this happens behind the scenes whenever you build an Uno head. + +## The end result + +Let's look at a concrete example. This is part of the markup we put in `MainPage.xaml` in a previous article: + +```` xml + + +