Implementation of a Apache Flex like ability to use percentage width and percentage height on all layoutable controls. #10184
Replies: 4 comments 5 replies
-
You could just create a custom panel to do this with AttachedProperties for PercentHeight etc rather like Canvas does for position. |
Beta Was this translation helpful? Give feedback.
-
I see different options here:
I hope it helps you a bit further. |
Beta Was this translation helpful? Give feedback.
-
While I could have just created a custom panel, I wanted to be able to use percentage based layout on all controls hense the modification to layoutable. It makes layout far faster and more intuitive than grid for me and my team as we have been using this system for 15 years. I can't think of a way though of adding the logic and properties into layout able as a 3rd party library without come really crazy IL injection and high jacking. I don't see any place were a plug in or IOC injection can modify layoutable or swap to a different layout able base since avalonia is using inheritance rather than decency injection for this. |
Beta Was this translation helpful? Give feedback.
-
There is an issue that % sizes can't work in some layouts eg. StackPanel makes itself as large as the children need so what would the % relate to. |
Beta Was this translation helpful? Give feedback.
-
I don't know how to create pull request, or how to even properly convey why this was incredibly important for me to be able to achieve. I really wish I could pull this off without having to modify the Avalonia source code, but since I wanted all controls to be able to do it I did have to make changes to the layoutable class to support PercentHeight and PercentWidth properties and a change to the Measure method to use those. Ideally I would like to also be able to use a percent since in the height and width properties so like and intercept the xaml transformation if it see thats, and instead set the percentwidth property correctly and set the width to NaN. If someone could help me figure out how to do that part that would be awesome. Hopefully this helps someone as much as it's going to help my team.
https://stackoverflow.com/questions/75331469/in-avalonia-or-xaml-in-general-how-would-i-implement-the-ability-to-use-percent/75331470#75331470
~ JT
Beta Was this translation helpful? Give feedback.
All reactions