Changes

XAML Tips

895 bytes added, 10:16, 11 April 2019
== Functionality related ==
 
=== Attachable behaviors ===
It's quite often that you need to attach behaviors to certain XAML elements. For example, on a Grid, you want to attach a behavior which executes a command upon a Tapped event like the following.
 
<source lang = "xml">
<Grid>
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Tapped">
<Core:InvokeCommandAction Command="{Binding NavigateToChildrenCommand}" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Grid>
</source>
 
 
Notice here that "Interactivity" and "Core" are both namespaces and you have to make sure that they are defined at the root of your XAMLs like the following.
 
<source lang = "xml">
<DataTemplate
...
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity">
...
</DataTemplate>
</source>
=== Fit mode ===