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.
Hello,
Thank you for your answer and for your sample, I now see your requirements better.
On question part A:
As far as I understand you need your RIA request to be finished with result delivered, before your click event rises. This issue is caused by the fact that by design all service calls in Silverlight work asynchronously. Many topics are being written according that matter. Here are two of them, people that are discussing inside this forums have similar issues to yours:
http://forums.silverlight.net/t/164774.aspx/1 http://stackoverflow.com/questions/6707704/silverlight-ria-services-with-synchronous-request
Nevertheless the behavior of our xamGrid is expected - the execution of the first method continues after the RIA call, and then it has finished, the second handler has being invoked. However the RIA service can be still processing and this is designed to be so, ever since Silverlight 4. Workarounds of this Microsoft architecture decision are discussed all over the Internet.
As to your question B:
Our grid deals with its building controls focus via the edit mode. Usually the no-editable cells, like all the cells that you have, are not meant for interaction and this is why when you change the active item, the loadData method can easily moves the focus to another element. In such cases the focus should be carefully controlled. I am not completely sure how this is relevant to the busy indicator you have used, so I was wondering if you could please elaborate on your sample
I will be looking forward to hearing from you.
Sincerely,
Ekaterina
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support
Hi Ekaterina,
First thanks for your investigations.
In attachment, you will find a new solution.
Outputs will be like that :
* Output 1 - when 1rst element is selected (click on edit button, no busy indicator) : --- LoadData() : Start loading data --- LoadData() : End loading data --- Click : Click on edit button => Correct : Click happen after end loading data * Output 2 - when 2nd element is selected (click on edit button, no busy indicator) : --- LoadData() : Start loading data --- Click : Click on edit button --- webService.SleepingServiceAsync() return : 14:23:29.1689413 --- LoadData() : End loading data => Correct : Click happen before end loading data, because of asynchronous call to web service * Output 3 - when 3rd element is selected (click on edit button, WITH busy indicator) : --- LoadData() : Start loading data --- webService.SleepingServiceAsync() return : 14:23:38.3928779 --- LoadData() : End loading data => NOT correct : because BusyIndicator move focus out of button, no click event is raised
I agree with your explanation. If there is an asynchronous call in LoadData(), this method will finish just after call. Then Click event will be fired before asynchronous call will be completed.
I was not able to find a solution for that, but it is not the main problem.Il would prefer to fix "Question part B : fosus" instead.
On question part B:
As you can see in "Output 3", because of BusyIndicator, Click event is never raised.I know how to : - get actual control with focus - show busy indicator - hide busy indicator - restore focus to control
But click event is still not firered automatically and I cannot know that user made a click on the button.Do you know a solution for that ?
Thanks for your help.
Another way to fix our problem would be to have the "button click" event firered before "row selection" event.
Is this possible ?Regards.
Yesterday we found another solution :
Like this MouseLeftButtonDown is raised before any other event.
Anyway, thanks for all the time you guys spent to help us.
Regards.
Alain.
I am just checking your progress on the issue.
If you require any further assistance please do not hesitate to ask.
Infragistics
www.infragistic.com/support
Hello Cosoluce_Stones,
I have been investigating into your issue, using your new sample that includes the BusyIndicator and the web service.
Since xamGrid is handling the events of its child objects, what happens is that when ActiveItem has being changed, the grid has handled the MouseLeftButtonDown event, but the buttons click event has not been raised yet. At that moment the BusyIndicator steals the focus and prevent the button from raising its click event.
What you can do in order to keep you custom logic is to:
1. Create a method PeformAction(), which is being called in the btnEditElement_Click handler AND in your VeiwModel class in the SleepingServiceCompleted’s body .
Or
2. Use other control that does not steals focus instead of the BusyIndicator.
If you explicitly call the btnEditElement_Click event, you will miss your event arguments, so extracting your functionality into a new method and calling it instead of explicitly call btnEditElement_Click event is preferable.
Please let me know if you need any further assistance regarding the discussed matter.