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 complete and documented answer.
I will split my reply in 2 parts : the two events firing and the click event not fired.
A - the two events firing timing.
I agree with you that applicaiton is single threaded.But I don't agree with "one of them fires first, its body executes, then the second handler has being executed".
In the case of the grid, row "selection" event is fired first (selected item is updated by the grid).But "click" event can fire even before the first one finish. For example if you load data from database in first event (RIA services), it takes some times. So as per my tests, while client is waiting for server answer, it can do something else (like firering "click" event).
(See solution in attachment : if LoadData() is calling RIA services, "click" event fire before first one finish.
B - Click event not firering when focus lost
In attachment, you will find a solution showing problem whith focus on a button in a cell of XamGrid.For tests purpose, focus is going to be modified during data loading, only for 3rd row.So to test the solution : 1 - Click on firstname of 2nd row in the grid 2 - Output is : --- LoadData() : Start loading data - can take a while --- LoadData() : End loading data => ok, only "selection" event has been raised 3 - Click on edit of 1rst row in the grid 4 - Output is : --- LoadData() : Start loading data - can take a while --- LoadData() : End loading data --- Click : Click on edit button => ok, because both events are raised 5 - Click on edit of 3rd row in the grid 6 - Output is : --- LoadData() : Start loading data - can take a while --- LoadData() : End loading data => not correct : only "selection" events is raised. "click" event not raised because focus has been lost.Our problem is when we are using BusyIndicator.Because it is displayed during data loading (process can take a while), focus is move out of button and click event is never raised.So in this configuration, do you know if there is a solution to have 2 behaviors on XamGrid cells ? Like this : a - click on a cell (firstname, lastname) will select row and raise "selection" event => standard behavior b - click on button doesn't raise "selection" event : - only "click" event is raised - inside "click" event, is there a way to know on which row user made the click and is there a way to "force" row selection (after some of our code) ?Thanks for your help.Alain.