I know this because I put a breakpoint on the event handler and its not breaking as I add items to the collection.
Here's where I'm setting the event handler (in the USERCONTROL's Loaded handler:
this
.selectedAttributes.RowAdded += new EventHandler<Infragistics.Controls.Grids.RowEventArgs>(selectedAttributes_RowAdded);
Here's where I'm connecting the ObservableCollection to the XamGrid:
cvsSelectedAttributes.Source = vm.SelectedAttributes;selectedAttributes.ItemsSource = cvsSelectedAttributes.View;
In case its not obvious:vm.SelectedAttributes is an ObservableCollectioncvsSelectedAttributes is a CollectionViewSourceand selectedAttributes is a XamGrid
I've already tried removing the CollectionViewSource and connecting the ObservableCollection directly to the grid, like so:
selectedAttributes.ItemsSource = vm.SelectedAttributes;
It didn't help.
Here's the event handler:
void selectedAttributes_RowAdded(object sender,Infragistics.Controls.Grids.RowEventArgs e){ SelectedAttributes dataGrid = (SelectedAttributes)sender;
if (dataGrid != null) { dataGrid.ScrollCellIntoView(e.Row.Cells[0]); }}
The items are appearing as new rows in the XamGrid. Why on earth is this event not being fired? Am I missing a property setting or something else?
Pleas help ASAP!
Hi Joe,
Even though I have gone through it countless times, I have not encountered such a statement in the documentation.
Please let me know if I can be of any further assistance on this matter.
>> Regarding the documentation, there is no emphasis, since most events work in such a manner.
Is it stated someplace in the documentation, that I have overlooked, that most events behave in the manner you describe? If so, I'd appreciate if you would point me to it.
Thanks,
Joe
I am really glad to hear this solves your issue. Regarding the documentation, there is no emphasis, since most events work in such a manner.
If the behavior is otherwise there is a solid reason for that, however if you think of it not firing most of the numerous events from coded actions, does have its effect on performance and know that your code should trigger any follow up action does allow you to react accordingly on your own.
Hope this clarifies things.
That works.
I am still disappointed that the RowAdded event only works from the UI!
At the very least, the documentation should be updated to note (with emphasis) this limitation. Had the documentation alerted me to this, it would have saved many hours of frustration.
Thank you for your assistance,
I see what you mean, however the intent of the event itself is to accommodate and register adding records through the XamGrid’s UI. Any actions that are triggered and can be handled through code are not supposed to trigger events in order to optimize performance and because as developers we can correspond to them with code. Regarding your particular question, I gave it quite some though in order to come up with a few approaches, however I am particularly happy with the last one. In the observable collection’s CollectionChanged event I used the Dispatcher’s BeginInvoke method, to make sure the body of the underlying function is executed after the item that is being added at that moment, has time to make it to the XamGrid and be present there when I set it to the XamGrid’s ActiveItem property. This in turn automatically sets the corresponding Row’s first Cell as Active cell and we are able to use the ScrollCellIntoView. Here is a code snippet for the above:
void people_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
Dispatcher.BeginInvoke(new Action(() =>
xamGrid1.ActiveItem = e.NewItems[0];
xamGrid1.ScrollCellIntoView(xamGrid1.ActiveCell);
}), null);
}
Please let me know if I can be of any further assistance on the matter.