c# - To change datepicker loaded event in xaml.cs to viewmodel relay commands in xaml wpf (with mvvm pattern) -


i trying move datepicker loaded event in xaml.cs view model. don't want code behind in xaml.cs.

xaml code given below,

<datepicker borderbrush="lightblue" borderthickness="1"  name="dttiervalidto"  isenabled="{binding canedit}" displaydatestart="{binding tierdealvalidfromdate, mode=oneway}"    selecteddate="{x:static sys:datetime.now}"   displaydate="{x:static sys:datetime.now}" width="120" horizontalalignment="left"> <i:interaction.triggers>    <i:eventtrigger eventname="loaded" >    <cmd:eventtocommand command="{binding dttiervalidto_loaded}"     passeventargstocommand="true" />    </i:eventtrigger> </i:interaction.triggers> </datepicker> 

viewmodel.cs code below..

public relaycommand dttiervalidto_loaded { get; protected set; } dttiervalidto_loaded = new relaycommand(dttiervalidto_loaded);    private void dttiervalidto_loaded()  {  datepicker dttiervalidto =  new datepicker(); //datepicker dttiervalidto = sender datepicker;  dttiervalidto.blackoutdates.adddatesinpast();  } 

but the problem is, event not getting triggered.

could here

try approach

<i:interaction.triggers>                     <i:eventtrigger eventname="loaded">                         <i:invokecommandaction command="{binding dttiervalidto_loaded}"/>                     </i:eventtrigger> </i:interaction.triggers> 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -