Changes

XAML Tips

831 bytes added, 06:56, 27 June 2019
/* Attachable behaviors */
=== 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 , or you want to execute a command when a certain property on a UBIK object changes. Notice that in the followingexamples, "Interactivity" and "Core" are both namespaces and you have to make sure that they are defined at the root of your XAMLs: <source lang = "xml"><DataTemplate ... xmlns:Core="using:Microsoft.Xaml.Interactions.Core" xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"> ...</DataTemplate></source> ==== Event Triggered ====With an EventTriggerBehavior, you can react on changes/events of UI Elements:
<source lang = "xml">
</source>
==== Data Triggered ====Notice here that "Interactivity" and "Core" are both namespaces and If you have want to make sure that they are defined at the root react on changes of your XAMLs like the followingunderlying data (ViewModel), you can use DataTriggerBehavior instead.The following example, when used in the ''UBIKSplashArea'' template, automatically navigates to the root objects once the login process is finished and the user was successfully authenticated:
<source lang = "xml">
<DataTemplateGrid> .. <Interactivity:Interaction.Behaviors> xmlns: <Core:DataTriggerBehavior Binding="using:Microsoft.Xaml.Interactions.Core{Binding IsLoggedIn}"Value="True"> xmlns <Core:InteractivityInvokeCommandAction Command="using:Microsoft.Xaml.Interactivity{Binding NavigateToRootPageCommand}"/> </Core:DataTriggerBehavior> </Interactivity:Interaction...Behaviors></DataTemplateGrid>
</source>
 
=== Fit mode ===