pawail rana pawail rana - 3 years ago 148
C# Question

Event Setter issue of RadGrid wpf

Hello Event Setter handler not working for MouseLeftButtonDown. Check xaml

<Style TargetType="telerik:GridViewRow">
<EventSetter Event="MouseLeftButtonDown" Handler="GridViewRow_MouseLeftButtonDown"></EventSetter>

But it's working for PreviewMouseLeftButtonDown. Event is valid for both. No any error occurred during execution. What is the reason? And how to make handler command with mvvm? Actually we are using MVVM for my app. So I have two issue. Please provide need full solution.

Answer Source

MouseLeftButtonDown is not valid with Event setter so please add MouseLeftButtonDown event with RowLoaded event. Something like will be as

 var row = e.Row as GridViewRow;
        if (row != null)
      new MouseButtonEventHandler(GridViewRow_MouseLeftButtonDown), true);

And method will be

 private void GridViewRow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

It will be work fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download