Page 1 of 1

OnVisualChildrenChanged not found

Posted: 11 May 2023, 16:06
by DevFear
Good afternoon. In WPF, you can override the OnVisualChildrenChanged method to work with changing child elements inside the element. The method is not detected in Noesis. I work with my custom StackPanel. Source: https://learn.microsoft.com/en-us/dotne ... esktop-8.0

Re: OnVisualChildrenChanged not found

Posted: 12 May 2023, 11:28
by sfernandez
As it happens with GetLayoutClip, this method is not yet exposed to C#, could you also add this to our bugtracker?

Re: OnVisualChildrenChanged not found

Posted: 12 May 2023, 11:35
by DevFear
Is there information about collections in various elements? Removed, added, etc. events?? In ItemsControl, I also didn't notice any tools for working with the collection.

Re: OnVisualChildrenChanged not found

Posted: 12 May 2023, 11:48
by DevFear

Re: OnVisualChildrenChanged not found

Posted: 12 May 2023, 13:03
by sfernandez
Thanks for the report.
Is there information about collections in various elements? Removed, added, etc. events?? In ItemsControl, I also didn't notice any tools for working with the collection.
The ObservableCollection has the CollectionChanged event, but ItemsControl.OnItemsChanged virtual method is not exposed to C# either. If you need it please report that too.

Re: OnVisualChildrenChanged not found

Posted: 14 May 2023, 14:20
by DevFear
That is, there are no ways to work with child elements inside the panel? As with ItemsControl, etc.?

Re: OnVisualChildrenChanged not found

Posted: 15 May 2023, 11:35
by sfernandez
We didn't initially expose all the API to C# because when working with a MVVM pattern you don't usually need to deal with custom controls. Instead you work with ObservableCollections to interact with the collections of items in your data model.

Could you elaborate a bit more what are you trying to accomplish?

Re: OnVisualChildrenChanged not found

Posted: 15 May 2023, 11:45
by DevFear
Sometimes there are times when decisions need to be made quickly, without MVVM. For example, create your own layout mechanisms in Panel, etc. Otherwise, for simple examples, you would constantly have to create some kind of complex wrapper of business logic.

In this case, I wanted to modify the StackPanel and add something like Spacing to it. In WPF, I would just redefine OnVisualChildrenChanged and add space to the child elements. Then you would have your own custom panel that could be used both with and without MVVM.

But I think you can also do it through MeasureOverride and ArrangeOverride, which turned out in another example: viewtopic.php?t=2936 .