Hello,
In the following blog post
http://blogs.infragistics.com/blogs/devin_rader/archive/2011/06/01/using-behaviors-to-synchronize-selected-items-of-infragistics-silverlight-controls-to-a-viewmodel.aspx
it describes how to use behaviors to sync up properties in your ViewModel . This method can similarly be used in both Silverlight and WPF to add binding for command processing.
For example, by creating an ICommand Dependency Property in your Behavior you can then create a binding between a command in your ViewModel and a control’s event.
I have attached a sample demonstrating this using Relay Commands and Behavior to execute a command in the ViewModel on the Double Click event of the XamDataGrid.
Sincerely,
Valerie
Developer Support Engineer
Infragistics
www.infragistics.com/support
Valerie,
Thanks so much for the code sample. That's the exact pattern that I'm building out using the XamDataGrid so your code has gotten me pretty far down the road. I've run into a problem in my code that I'm hoping you've seen before or can maybe shed some light on what I'm doing wrong.
As you can see in the attached screenshot, I'm getting a null object reference in the class included in your sample but I can't figure out why. To be clear, your class works in your sample so I'm trying to figure out what I missed in plugging it into my app. At the top of the screenshot I show where the ClickedCmdProperty is set (from the binding in my XAML page) but when ClickedCmd is referenced it is null. The screenshot doesn't show it but r.DataItem has precisely the record of data that I want to process. It's ClickedCmd that doesn't have a value. Any ideas as to what would cause that behavior?
Best regards,
Dempsey
Looks like the screenshot got cut off. The top portion shows this:
Hello Dempsey,
Perhaps it could be that the binding in the XAML is incorrect:
<i:Interaction.Behaviors> <local:XamDataGridDoubleClickBehavior ClickedCmd="{Binding SelCommand}"/> </i:Interaction.Behaviors>
Do you see any binding errors in the Output window when you run your app?
Sincerely,ValerieDeveloper Support Engineer Infragisticswww.infragistics.com/support
Thanks for getting back to me. That was it! I'm new to WPF development so I didn't catch that an error like that would not stop compilation. I'll be more mindful of the Output messages now.
Have an awesome weekend! Many blessings on you!