Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAML grid layout with different combinations

Tags:

c#

wpf

xaml

My WPF application will be extracting usernames from a database and I want to display a button with each persons username on it on a WPF page.

I don't know the number of users before hand so I want to change the size and position of the buttons depending on the number to display.
For example:

  1. If there is one user display one button in the center of the screen.
  2. If there is 4 users display 4 buttons in a 2x2 grid layout.
  3. If there are 8 users display 8 buttons in a 3x3 grid with the 9th gird position blank.
  4. And so on up to 64 users (8x8 grid)

How can I do this using XAML??

like image 824
Harry Boy Avatar asked May 24 '26 13:05

Harry Boy


1 Answers

WPF Uniform grid control is suitable for your requirement. It will come with row and columns. Grid will take care of automatic arrangement of elements.

like image 50
ReeganLourduraj Avatar answered May 27 '26 01:05

ReeganLourduraj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!