windows phone 8 - How to change the position of dynamic buttons in wp8 c# -


in windows phone application creating dynamic button below:

    <grid x:name="contentpanel" grid.row="1" margin="24,0,0,0">         <textbox x:name="tb_groupname"              height="90"              background="white"               margin="0,0,125,517"               foreground="blue" textchanged="tb_groupname_textchanged" gotfocus="tb_groupname_gotfocus" lostfocus="tb_groupname_lostfocus"/>         <button x:name="btn_groupname"                 content="add"                 background="aliceblue"                 foreground="blue"                 fontsize="25"                 width="120"                 height="90"                 horizontalalignment="right"                 verticalalignment="top" click="btn_groupname_click"></button>         <listbox x:name="lb_groupofcontacts" itemssource="{binding}" margin="0,118,0,0">          </listbox> 

and below xaml.cs page code

private void btn_groupname_click(object sender, routedeventargs e) {     if (tb_groupname.text != string.empty)     {         list<button> buttons = new list<button>();                 button btn = new button();// cast control button.             btn.content = tb_groupname.text;             btn.width = 200;             btn.height = 200;             btn.click += new routedeventhandler(btn_click); // add event button.             buttons.add(btn);             buttonname = tb_groupname.text;             tb_groupname.text = string.empty;          lb_groupofcontacts.datacontext = buttons;     }  } 

and add button listbox lb_groupofcontacts when create dynamic button map onto previous button means not change position of button

and want

first button created on top left second button created on top right third button created on center left forth button created on center right fifth button created on bottom left sixth button created on botton right 

kindly suggest me how change position of above or if know other way change position of dynamic both tell me, waiting reply. thanks.

first of creating object of list button_click every time creating new list , adds only new 1 button , taking list listbox's content not able add second button.

you can set position of button dynamically by:

btn.margin = new thickness(left,top,right,bottom); 

or

btn.horizontalalignment = system.windows.horizontalalignment.left; btn.verticalalignment = system.windows.verticalalignment.center; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -