Reputation: 3498
While developing a universal windows app (uwp) I frequently need to look up how to do different things in XAML.
One problem is, that all too often I end up with a solution for WPF or Silverlight or Windows Phone which is not applicable to an UWP app. Is there a good overview with differences between the various dialects?
If not, could this be something which is a part of the upcoming stackoverflow documentation feature. I'm very willing to participate with the things I'm already aware of.
Upvotes: 15
Views: 2358
Reputation: 3498
{x:Bind}
markup extensionDatabings are essential for working with XAML. The XAML dialect for UWP apps provides a type of binding: the {x:Bind} markup extension.
Working with {Binding XXX} and {x:Bind XXX} is mostly equivalent, with the difference that the x:Bind extension works at compile time, which enables better debugging capabilities (e.g. break points) and better performance.
<object property="{x:Bind bindingPath}" />
The x:Bind markup extension is only available for UWP apps. Learn more about this in this MSDN article: https://msdn.microsoft.com/en-us/windows/uwp/data-binding/data-binding-in-depth.
Alternatives for Silverlight, WPF, Windows RT: Use the standard {Binding XXX} syntax:
<object property="{Binding bindingPath}" />
Most of the time you need to import namespaces in your XAML file. How this is done is different for the different XAML variants.
For Windows Phone, Silverlight, WPF use the clr-namespace syntax:
<Window ... xmlns:internal="clr-namespace:rootnamespace.namespace"
xmlns:external="clr-namespace:rootnamespace.namespace;assembly=externalAssembly"
>
Windows RT, UWP use the using syntax:
<Page ... xmlns:internal="using:rootnamespace.namespace"
xmlns:external="using:rootnamespace.namespace;assembly=externalAssembly"
>
Multi Binding is a feature exclusive for WPF development. It allows a binding to multiple values at once (typically used with a MultiValueConverter).
<TextBox>
<TextBox.Text>
<MultiBinding Converter="{StaticResource MyConverter}">
<Binding Path="PropertyOne"/>
<Binding Path="PropertyTwo"/>
</MultiBinding>
</TextBox.Text>
</TextBox>
Platforms other than WPF don't support multi binding. You have to find alternative solutions (like moving the code from view and converters to the viewmodel) or resort 3rd party behaviours like in this article: http://www.damirscorner.com/blog/posts/20160221-MultibindingInUniversalWindowsApps.html)
Upvotes: 7
Reputation: 1159
Hello sometime ago when I was starting to write for UWP I found an article that really helped me. Take a look here. Also There was already a question about this in StackOverflow here
Upvotes: 0