MCC KWC

MCC KWC

  • NA
  • 1
  • 560

How to dynamically arrange buttons in Windows phone 8 app

Sep 4 2015 3:07 AM
Here is my code............
 
 
int i = 0; int j = 0;
int button_number = 1;
foreach (var element in jsonObj.ds.Table)
{
depot_collection.Add(element.depot);
Button btn = new Button();
btn.Height = 160;
btn.Width = 160;
btn.Content = element.terr;
btn.Background = new SolidColorBrush(Colors.Blue);
btn.Foreground = new SolidColorBrush(Colors.White);
btn.BorderBrush = new SolidColorBrush(Colors.Blue);
btn.Margin = new Thickness(-300 + (j * 290), 200 + (i * 290), 0, 0);//- (extra_row * 275),
LayoutRoot.Children.Add(btn);
if (button_number % 3 == 0)
{
i++;
j = 0;
}
else
{
j++;
}
button_number++;
}
 
 
Am I forward on right way? or have there any better concept to do this? 

Answers (1)