views:

1596

answers:

2

It is easy enough to create a command from my OnLoaded() event handler code, but how do I call it from the View?

<window Loaded="onLoaded"> doesn't cut the cake anymore since it calls code in the xaml.cs. How would I create an ICommand equivalent?

+5  A: 

You can do this sort of thing via an attached behavior. To save yourself some time, take a looked at Marlon Grech's Attached Command Behavior library.

HTH, Kent

Kent Boogaart
A: 

You could use the MVVM Light Toolkit's event to command behavior: http://blog.galasoft.ch/archive/2009/11/05/mvvm-light-toolkit-v3-alpha-2-eventtocommand-behavior.aspx

Justin