Harry Boy
Harry Boy

Reputation: 4747

XAML grid layout with different combinations

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??

Upvotes: 3

Views: 115

Answers (1)

ReeganLourduraj
ReeganLourduraj

Reputation: 873

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.

Upvotes: 3

Related Questions