mvvm - How to fire a Command when a window is loaded in wpf -
It is possible to fire the command to notify the window. Apart from this, I am not using any MVVM framework (framework, caliberon, onxi, MVVM toolkit etc. in the sense).
To avoid code behind your view, use Interactive Library (System.Windows Interactivity DLL which you can download from Microsoft for free - also come with Expression Blend).
Then you create a behavior that executes a command, in this way the catalyst says that he calls the command.
& lt; Ia: interaction Trigger & gt; & Lt; Ia: Event Trigger Event Name = "Load" & gt; & Lt; Custombaviers: CommandAction command = "{Baid Showmess}" parameter = "I'm loaded" /> & Lt; / IA: EventTrigger & gt; & Lt; / IA: Interaction.Triggers & gt;
The command-action (System.indows. interactivity is also used) can look like:
Public Class Command Actions: Trigger Action & lt; UIElement & gt; {Public static dependency form commandproduct = dependency property. Control ("command", typef (icmand), typef (commandaction), blank;); Public eCommandand command {return (ICMMand) gateville (commandproperty); } Set {set value (commandproperty, value); }} Public stable dependency property parameter = DependencyProperty.Register ("parameter", type (object), typef (commandaction), blank); Public object parameter {GetValue (parameter property); } Set {set value (parameter property, value); }} Insert Safe Override Z (object parameter) {Command.Execute (parameter); }}
Comments
Post a Comment