Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4040
Two events : button click and row selection
posted

Hi,

We have a Xamgrid with several columns. First contains an "Edit" button.

We would like the following behavior :

      case 1 - click on "normal" (text) cell : launch data loading

      case 2 - click on "Edit" button :

                      a - launch data loading

                      b - switch to edit mode (not in the grid, this is some of our code)

In case 1, no problem as only one event is firered on row selection (ex : SelectedRowsCollectionChanged).


But in case 2, two events are fired :

          - First the one for row selection,

          - and then the button click

These two events are independent (not synchronized). So depending on how long takes first one to finish (loading some data), the second event can fire before the other one finish or not.

Is there a way for us to  synchronize these events ?

By the way if during case 2, the focus is moved out of button, click event is not firered.....


Regards.

Alain.

 

Parents
No Data
Reply
  • 4475
    posted
    Hello,
     
    I have been looking through your issue and I do understand your concerns.
     
    Normally programs in C# are single threaded – that means that each process ( tread) runs at a time. When you have placed a button inside a cell these are two independent objects and two click events are fired. Of course one of them fires first, its body executes, then the second handler has being executed.
     
    In order to force them to execute at the same time, you have to use multithreading technique. This approach causes two processes to be executed at the same time. However this is pretty risky, because often processes depend on each other and it is highly possible to get an error because of that. In case you would like to implement multithreading, you can refer to the link placed below, or to one of the many Microsoft articles dedicated on this topic :
     
     
    Otherwise, if you do not want processes to be executed in parallel, you can use many different custom approaches, depending on your code specification. For example, if your second code need to “wait a bit” until some sort of action has been done, you can use Dispatcher, or you can use some sort of flags that indicates the current actions state. Nevertheless, the behavior that you have described, is expected.
     
    As to your second issue, the event is not being fired when the focus have being moved out of the button – I am not quite sure that I have fully understood the scenario. How do you click on the cell that contains a button and you move the focus out of the button before its click event is being raised. Would you please explain me a bit more about this issue or even better – send me a simple isolated sample that shows the described behavior.
     
    Please let me know if I understood your requirements or I have misunderstand you at some point.
     
    Sincerely,
    Ekaterina
    Developer Support Engineer
    Infragistics, Inc.
Children