1

So I am using GalaSoft's EventToCommand for binding my View's Loaded event to my command in my ViewModel. The binding is working great but my Command is never being executed. The only way I have been able to get this to work is to handle the Loaded event in my View's code behind and then cast my DataContent to my VM and tell it to run my code (which the command is trying to do). Obviously this isnt very nice when trying to do it all MVVM like. FYI I did try the MouseEnter event and that worked great so that makes me think its a timing issue. Also, my View is a user control.

View:

<i:Interaction.Triggers>
    <i:EventTrigger EventName="Loaded">
         <cmd:EventToCommand PassEventArgsToCommand="False" Command="{Binding Path=DownloadDataCommand}" />
    </i:EventTrigger>
</i:Interaction.Triggers>

ViewModel:

public RelayCommand DownloadDataCommand
{
    get { return new RelayCommand(() => DownloadDataAsync()); }
}

Ive tried calling simple methods that do pretty much nothing and my relay command is still not invoked. So I doubt its the action within the RelayCommand. Does anyone see what I am doing wrong?

4

0 回答 0