WPF and UWP Comparison
Originally based on UWPvsWPF.md with Avalonia-specific changes.
This document is licensed CC BY-SA 4.0. For the full text of this license see: https://creativecommons.org/licenses/by-sa/4.0/legalcode
This section lists the main differences (primarily from a XAML viewpoint) between Avalonia, UWP and WPF.
Legend:
- ✔ Indicates the platform (defined by the Avalonia, WPF or UWP column) has the feature
- ✖ Indicates the feature is generally missing in the platform
- ⚡ Indicates the feature is only partially implemented compared to other platforms
Markup Extensions
Item | Avalonia | WPF | UWP | Notes |
---|---|---|---|---|
x:Uid for localization | ✖ | ✖ | ✔ | x:uid is a powerful localization system similar to what exists in Windows Forms. WPF is sorely missing this type of localization support. This is a clear advantage of UWP. |
x:Bind | ✖ | ✖ | ✔ | x:Bind has also become a powerful feature of UWP over WPF. Compiled bindings can be used for nearly anything and can replace other missing features like MultiBinding. Other advantages include debugging support as well as increased performance. |
x:Array | ✖ | ✔ | ✖ | x:Array isn't supported in UWP. |
x:Static | ✔ | ✔ | ⚡ | x:Static could be replaced with x:Bind |
x:Type | ✔ | ✔ | ✖ | |
x:True | ✔ | ✖ | ✖ | |
x:False | ✔ | ✖ | ✖ | |
Full Markup Extension | ✔ | ✔ | ✖ | UWP only implements a subset of the full markup extension support in WPF. This area needs to be expanded upon in the future. |
Compiled Bindings | ✔ | ✖ | ✖ |
Binding
Item | Avalonia | WPF | UWP | Notes |
---|---|---|---|---|
OneWayToSource BindingMode | ✔ | ✔ | ✖ | |
Binding to ConverterParameter | ✔ | ✔ | ✖ | |
MultiBinding / IMultiValueConverter | ✔ | ✔ | ✖ | Very useful feature in WPF for advanced binding scenarios no longer exists for UWP. UWP does have function binding with x:Bind though (Used to re-implement converter logic). |
ICommand | ✔ | ✔ | ⚡ | While the interface technically exists, ICommand is nothing like what it was in WPF. The programmer is now responsible for doing every little part of the command. This was improved in Windows 10 version 1809 which added XamlUICommand and StandardUICommand. |
RelativeSource / AncestorType | ✔ | ✔ | ⚡ | Not nearly as powerful in UWP, relative source only supports {RelativeSource Self} and {RelativeSource TemplatedParent} as compared to more powerful expressions in WPF like {RelativeSource PreviousData} or {Binding RelativeSource={RelativeSource Mode=PreviousData, AncestorType={x:Type TextBox}} . |
StringFormat | ✔ | ✔ | ✖ | XAML such as {Binding DateValue, StringFormat=Date: {0:dddd yyyy-MM-dd}} isn't supported in UWP and requires custom converters. |
Functions in binding | ✖ | ✖ | ✔ | x:Bind in UWP supports OneWay and TwoWay function binding that can replace converters. |
Styling
Item | Avalonia | WPF | UWP | Notes |
---|---|---|---|---|
DataTriggers / PropertyTrigger / EventTrigger within Style.Triggers | ✖ | ✔ | ✖ | |
VisualStateManager | ✖ | ⚡ | ✔ | A different concept from WPF that takes the place of DataTriggers, this is very verbose and more often than not increases complexity compared to data triggers. @Felix-Dev VisualStateManager does exist in WPF (it was added in .NET Framework 4.0). It's not as elegant as in UWP though, i.e. it has no VisualStateManager.Setters property. That means you have to use Storyboards to set your values. |
Implicit DataTemplate | ✔ | ✔ | ✖ | Set the DataType property of the DataTemplate to the corresponding type and the template is then applied automatically to all instances of that particular type |
Binding in Style setter | ✔ | ✔ | ✖ | Any other than TemplateBinding isn't support in a template/style within UWP |
BasedOn default Style | ✔ | ✔ | ⚡ | BasedOn={StaticResource {x:Type TextBlock} isn't supported in UWP but works in WPF. Instead, BasedOn requires the use of a key which is a problem as not all default styles define one. This is a specific example of the missing x:Type markup extension in UWP. |
Other
Item | Avalonia | WPF | UWP | Notes |
---|---|---|---|---|
Coercion | ✔ | ✔ | ✖ | Coercion of Dependency Properties is not supported in UWP. |
Data (Input) Validation | ✔ | ✔ | ✖ | The entire WPF data validation system including the classes/interfaces: ValidationRule (and all standard implementations), Binding.ValidationRules, IDataErrorInfo, INotifyDataErrorInfo, Binding.ValidatesOnNotifyDataErrors, etc. is not implemented in UWP. This will be added in WinUI 3.0 but the story for using this within the UWP app model with WinUI 3.0 is less clear. |
x:TypeArguments directive | ✔ | ✔ | ✖ | The TypeArguments directive isn't implemented in UWP which causes problems with generics. Missing this requires some work-arounds with classes and creating a non-generic class to use in XAML from a generic one. |
UIElement.IsVisible / IsVisibleChanged | ✔ | ✔ | ✖ | UWP has no way of tracking which controls are actually visible on the display. WPF has the UIElement.IsVisible property and the IsVisibleChanged event. This hinders the ability to optimize controls for performance. |
UIElement.Visibility / Visibility.Hidden | ⚡ | ✔ | ⚡ | UWP does not include the Visibility.Hidden enum value used for UIElement.Visibility. Hidden in WPF allowed a control to still be used in measure/layout but appear invisible when rendered for display. |
UIElement.Clip | ✔ | ✔ | ⚡ | Both WPF and UWP have UIElement.Clip properties. However, WPF can take any Geometry allowing for non-rectangular clipping. UWP can only use a RectangleGeometry for clipping. WPF: public Geometry UIElement.Clip, UWP: public RectangleGeometry UIElement.Clip |
UIElement.ClipToBounds | ✔ | ✔ | ✖ | In WPF it's possible to clip child contents to the parents bounds by setting ClipToBounds to True. UWP doesn't have this property at all. The work-around is to use UIElement.Clip which can only do rectangular clipping. |
LayoutTransform | ✔ | ✔ | ✖ | Layout transform is needed to transform elements before layouting. This allows for easily changing textbox direction and then putting it in a table. RenderTransform, as it applies after layout, does not resize parent controls for transformed children. |
VisualBrush / DrawingBrush | ✔ | ✔ | ✖ | VisualBrush is not a XAML brush in UWP. Instead, must fall back to composition brushes which are not 1:1 equivalent. DrawingBrush is not supported at all in UWP. |
Supplemental Shapes: Arrow, Callout, Star, etc | ✔ | ✔ | ✖ | Several shapes present in WPF are missing in UWP. |
Adorner | ✔ |