Monday 15 July 2013

windows phone 8.1 - Bind mvvm light Relaycommand to page loading event -



windows phone 8.1 - Bind mvvm light Relaycommand to page loading event -

i working on window phone 8.1. have relaycommand command executes method async. want know how can bind page load event page relaycommand in view model?

all illustration see binding relaycommand button.

how can bind page load event? see illustration uses eventtocommand. using window phone 8.1, dont' think have behaviour stuff article saw.

make sure add together behaviors extension references

then define event trigger invokes command:

<page x:class="app31.pivotpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:app31" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:data="using:app31.data" xmlns:i="using:microsoft.xaml.interactivity" xmlns:core="using:microsoft.xaml.interactions.core" mc:ignorable="d"> <i:interaction.behaviors> <core:eventtriggerbehavior eventname="loaded"> <core:invokecommandaction command="{binding mycommandintheviewmodel}" /> </core:eventtriggerbehavior> </i:interaction.behaviors> //.... //.. rest of page code

where mycommandintheviewmodel command in vm, , datacontext of page set vm.

mvvm windows-phone-8.1 mvvm-light

No comments:

Post a Comment