Is there a DataObjectChanging like event?

Grids for WPF Forum

Posted 7 years ago by Imre Lengyel
Version: 17.1.0652
Avatar

We have a scenario where with a property grid, we want to maintain the focused property when changing the DataObject. For this we would store the property path and re-focus after the new DataObject is set.

I see the RootItemChanged event for the second part of the solution, but I do not see a place to hook for the first part to capture the current focused property.

Thanks,

Comments (12)

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Imre,

There isn't a pre-change event just yet, but we will add a RootItemChanging event for the next version.  Thanks for the suggestion.


Actipro Software Support

Posted 6 years ago by Wiley Knoch
Avatar

Was this ever added to the roadmap and completed?  I am ugrading from 16 - 18 now to use the new grid and lost the selection items changed to have the old and new DataObjects and still don't see an event like this.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Wiley,

We did added it but after doing some testing with another customer, we found it wasn't helpful since by the time the RootItemChanging event fired, the new item was already assigned. 

What specifically were you looking to track, the old selected item?


Actipro Software Support

Posted 6 years ago by Wiley Knoch
Avatar

Correct I need access to the old and the new.  The previous property grid used the selected items changed even which supplied both so I can hook up some of my specialty event tracking and didn't see anything in the new version with a similar event.

Posted 6 years ago by Imre Lengyel
Avatar

Hi Wiley,

Quite a memory test, but from what I remember, we had to handle capturing the prop grid state before updating the DataObject property, and best effort re-apply state after the set.

I have seen another solution where proxy object is used for the data object, which has the advantage of reducing some flicker when changing objects, but in that solution the properties in data objects were flat, and the property shape of the objects were the same.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Wiley,

I believe the SelectionChanged event (defined on the base TreeListBox class) does pass a SelectionChangedEventArgs that specifies removed and added items.  In the case of PropertyGrid, those items will be data models like IPropertyModel.


Actipro Software Support

Posted 6 years ago by Wiley Knoch
Avatar

SelectionChanged event is now fired when the actual selection changes in a property grid, clicking on different properties in the grid.  Before this event was fired when the SelectedObjects changed which is now be changed to DataObjects in the new grid.  I have a work-around in place using the OnItemsSourceChanged override but it is hacky and was just wondering if the question asked in this inital post had been addressed yet.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Wiley,

The SelectionChanged event should still be getting fired as new DataObjects are set, even in the new PropertyGrid.  

We don't yet have anything built-in for the original question.  We have a TODO list item for that and I've added your request to it.


Actipro Software Support

Posted 2 years ago by Procam
Avatar

Hello Actipro,

after 4 years, is already there a built-in solution for the original question? if yes, in which version?

Thx!

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We had started a code branch a while back to persist state but never completed it.  I assume you are switching PropertyGrid.DataObject(s) here and simply want to keep the same general expansion/selection/scroll state after the switch?

How would you like this feature, if added, to be enabled API-wise?


Actipro Software Support

Posted 2 years ago by Procam
Avatar

Hello, my question is related to the thread https://www.actiprosoftware.com/community/thread/25865/category-name-translation#120642
As it seems too much expansive to re-template the Grid, I am looking for another way how to update the Category name using the Display attribute and then setting the categoryModel.DisplayName when language and/or DataObject(s) changes (even a cleaner solution should be the XAML approach in the another thread):

            foreach (DataModelBase item in cpg.Items)
            {
                if (!(item is CategoryModel cm)) continue;

                cm.DisplayName = TranslationManager.Instance.Translate(cm.Name);
            }
Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Procam,

We replied to you in the other thread with another programmatic way to achieve this.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.