I've been looking almost all night for a way to have this nice "add" button at the bottom of a ListBox. The thing is I want it to stick at the bottom of the listbox, and then once the bottom of the border is reached, I want the listbox to become scrollable so that the add button doesn't get out of the border. Right now I do it with two rows but I would like the button to be precisely at the bottom of the list, while still not going out of the border when the list grows bigger. Any Idea ? Thanks in advance
Asked
Active
Viewed 308 times
-1
-
Why isn't it just a button outside the listbox and underneath it? – Andy Apr 03 '20 at 19:58
-
`
-
@Andy the thing is when the listbox grows bigger the button goes out of the border. I would like it to stop nicely at the bottom of the border and then the listbox would become scollable. But thanks anyway – Marcel Barc Apr 03 '20 at 22:05
1 Answers
-1
Okay so I finally found my way through this simple yet annoying thing : The trick was to use a DockPanel and put the button at the bottom, while having all the controls vertically aligned to the top.
<DockPanel Height="Auto" VerticalAlignment="Top">
<Button Width="20" DockPanel.Dock="Bottom" VerticalAlignment="Top"/>
<ListBox VerticalAlignment="Top"/>
</DockPanel>

Marcel Barc
- 137
- 1
- 9
-
No point in downvoting without explaining why.. What's wrong with this answer ? – Marcel Barc Apr 05 '20 at 10:21
-
Doesn't work for me: The button still sticks to the bottom (which DockPanel.Dock="Bottom" is supposed to do) – user2727133 Mar 14 '22 at 18:44