Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
189 views
in Technique[技术] by (71.8m points)

MVVM Light: Adding EventToCommand in XAML without Blend, easier way or snippet?

Can anyone tell me what the actual syntax is for EventToCommand class. From what I believe is that EventToCommand class works with Silverlight / WPF and WP7, hence I think its a better choice to go down.

From what I believe, I can add any click event and get it forced into my ViewModel, but I am having an issue in finding the best way to do this.

I know you can add it without Blend, but are there snippets available?

Or is there an easier way to add it via VS 2010? Any help or if anyone knows of a good tutorial on this would be great.

question from:https://stackoverflow.com/questions/5868589/mvvm-light-adding-eventtocommand-in-xaml-without-blend-easier-way-or-snippet

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Suppose you use .NetFramework4:

First add namespace:

xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"

Syntax for the Loaded event.

<i:Interaction.Triggers>
    <i:EventTrigger EventName="Loaded">
        <cmd:EventToCommand Command="{Binding Mode=OneWay, Path=LoadedCommand}"
                            PassEventArgsToCommand="True" />
    </i:EventTrigger>
</i:Interaction.Triggers>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...