-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
st.AutoGrid MarginBetweenChildren #4
Comments
Thanks! I really like the MarginBetweenChildren too. It's the main reason I wrote StackPanel. I would love to see it in AutoGrid as well, but it would be fairly difficult. The main problem is that it's derived from Grid. It's definitely possible though. Maybe I'll get to it at some point. I'd gladly take pull requests. :) |
My idea is to make
|
That is one way to implement it. However, the problem with that approach is what do you do if the consumer chooses both <st:AutoGrid Columns="Auto,*" MarginBetweenChildren="10" ChildMargin="0,5">
<TextBlock Text="First Name"/>
<TextBox/>
<TextBlock Text="Last Name"/>
<TextBox/>
<TextBlock Text="Gender"/>
<st:StackPanel MarginBetweenChildren="10" Margin="20,0">
<RadioButton Content="Female"/>
<RadioButton Content="Male"/>
<RadioButton Content="Other"/>
</StackPanel>
</st:AutoGrid> What should everything calculate out to? In the current version, AutoGrid would let the children override the parent's choice (as it should). In StackPanel, There's also other issues. As a consumer, I'd love to chose a different margin horizontally vs vertically. Things get complicated quickly. I'm open to suggestions, though. |
I like The
To set the different horizontal and vertical margins, one would just set Maybe better name would be |
I like where your head is at, however, if I was to implement it in that manner, I believe MarginBetweenChildren would lose some its luster. The idea was two fold. First, stop applying a trailing margin to all children except the last. And second, stop trying to calculate a magical number that would give you the margin between children you want, as well as the margin around the container. With the last UX designer I worked with, the margins were simple: 10px between each element and 10px around the container. That meant that everything could have a margin of 5px and it would all add up to the 10px we wanted. Simple and magical. But when you start wanting the margin around your container to be different from the margin between the children, things get complicated. In order to get 10px between the children and 20px around the left and right side of the container you have to set your children's margin to 5 and your parent's margin to "10,0". And even then you are left with 5 extra margin on the top and bottom. Not ideal. Your solution fixes part of the problem. You can apply zero margin to the outside edge of children not in the center. But you still have to cognitively calculate the additive margin of children next to each other. I think this is good, but not great. In order to do what I would really want, which is space elements out and then apply the child's margin after that, would require me to take full control over the child's sizing and positioning. That would mean replacing the entire grid's functionality. That is something that I am not ready to tackle. The Grid is complicated. The StackPanel is simple. That's why I went with the StackPanel. I was able to get my idea working in a few hours. Also, I found myself using AutoGrid as a very expensive StackPanel in order to get the fill capability. I honestly don't use a true multicolumn & multirow Grid very often. In fact, the typical use case is for forms controls. Instead, what I do is create a custom ContentControl called FormControl with a Label dependency property. Then I style that to my heart's content. And I use that in a stack panel. If I need two columns then it is a stack panel of stack panels. This simplifies my UI immensely. |
Now I see the point of the |
I like the new
st:StackPanel
MarginBetweenChildren
property. I would like to add it to thest.AutoGrid
, too. Thest.AutoGrid
hasChildMargin
property already. It can be overridden, when an element specify it's own 'Margin'. I would like theMarginBetweenChildren
behave the same way for thest:StackPanel
andst.AutoGrid
, too.The text was updated successfully, but these errors were encountered: