Consider unsealing the Render() of the Panel? #15992
Replies: 12 comments 2 replies
-
|
+1 ! |
Beta Was this translation helpful? Give feedback.
-
|
+1 me too |
Beta Was this translation helpful? Give feedback.
-
|
It is sealed because we may want to change how things work in the future and if it wasn't sealed, that may lead to conflicts and breaking changes. Also I suggest to just add the sepator to ContainerItemTheme and if needed hide it for the last item. We have nth child selectors which could be useful here as well. |
Beta Was this translation helpful? Give feedback.
-
|
@timunie Thank your for your reply! Yes, I do this now. But it feels that putting the separator into the item container template is not lightweight enough. I should at least add a panel and a separator. In addition, I have to think about the layout of the separators in my mind so that they are accurately placed in the center of the two containers, which is troublesome to do. Even if I may need to place similar separators in different types of list controls, I need to modify the control template of each list container. Unsealing the Panel's Render function will give the Panel more flexible extensibility, although it is optional. If the user overrides the panel's Render function, then the user needs to be responsible for it. Render will only perform some additional auxiliary drawing and will not have an additional impact on the main function of the Panel-layout, which seems to be no breaking change. In contrast, allowing users to control measurement and layout arrangements seems to be more likely to cause conflicts and breaking changes, but this is inevitable, right? |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, it's not that simple, particularly for selectable items. The separator will visually appear as contained in the selectable/selected item, which does not make sense. It still doesn't mean that overriding To create the separators as visual children, it is as "simple" as overriding this method appropriately: Avalonia/src/Avalonia.Controls/Panel.cs Line 134 in 82e3613 It's not very easy, but it should be maintainable and work well with virtualization if implemented correctly. |
Beta Was this translation helpful? Give feedback.
-
That's right. This is a reasonable approach, if we only add separators to the list and do not do other operations such as iteratoring visual children. Whether the separator is added in the control template or in the Children of the Panel, it is always a Visual in the visual tree. In some complex scenarios, we need to give them more attention. What I mean is that we can use different ways to achieve this goal in different scenarios. Whether it is overriding the control template, overriding the Panel's ChildrenChanged, or overriding Render, these methods may be suitable for various scenarios. If the Render method can be unsealed, the Panel will gain greater flexibility, even if this flexibility is not reflected in the scenario of adding separators, in some cases. |
Beta Was this translation helpful? Give feedback.
-
|
can this be simplify in any way |
Beta Was this translation helpful? Give feedback.
-
|
Agree, this change was unfortunate. My ugly workaround is: https://github.com/BAndysc/WoWDatabaseEditor/blob/ad03280fc13e3544e46d0b1ace550973c72ef4f6/AvaloniaStyles/Controls/ControlRenderer.cs Basically, it inserts an extra Control as the first child of the RenderedPanel, which is used as a "renderer" for the Render method. |
Beta Was this translation helpful? Give feedback.
-
|
In fact, in normal development, we need to redraw complex lines and layouts for the ItemsPanel in ItemsControl. Now we need to re-render the Panel, but since the Rendering problem is sealed, we developers cannot perform advanced drawing and customization. Since developers have thought of using Rendering, they must bear the tedious processing problems brought by Rendering. I think there should be no Avalonia project members to control this problem, which has brought great inconvenience to developers. In order to solve the drawing problem, we have to redraw templates and recombine controls in large quantities to achieve the effect. |
Beta Was this translation helpful? Give feedback.
-
|
With full respect to the team. I write this to guide someone who search the answers for these type of questions: This is one of the decisions I fully disagree with. And no matter what I think and what they think sometimes you need a solution right now or tomorrow. Discussing this is waste of time and even if you will convince the team to make it public - a new version will launch no one knows when. In a week? can be a 3 months. My approach is to make a full fork (it's closed source, sorry) and make public everything I need. When Avalonia makes an update all I need is to perform an easy auto-merge. |
Beta Was this translation helpful? Give feedback.
-
|
We need to override the With respect to the Avalonia Team and Thanks for their awesome works, It seems there is a Revolution of Internalizing of usefull things (or Sealing Overridable Methods) are occuring in newer avalonia releases. If it is intended to replace an existing feature nextly with better one (which may lead to break changes), The true way is not to abandon the existing feature immediately (before the new one become) and harm the project's good atmosphere. As I know, there is some Attributes exists in Avalonia to warning developer, which maybe usefull in these situations. Obviously, some projects need to customize existing controls including With Best Regard. |
Beta Was this translation helpful? Give feedback.
-
|
At some point we can just replicate code from Panel and unseal
I can accept that all sub classes of Panel have Render sealed, but Panel as the base class and the only accepted implementation of ItemsPanelTemplate, should not be sealed like this. @avaloniaui-team @MrJul |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
I would like to put separators between some ListBoxItem. Just like :
Item | Item | ItemSo I want to extend the StackPanel and render some separators on it. It is the simplest way to do that, I think.
BUT, the Render() of Panel is sealed.
Describe the solution you'd like
Could you please unseal the Render() of the Panel. I can not come out why it is sealed, in my opinion.
Describe alternatives you've considered
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions