c# - How do I one element align to the left, and another align to the right? -


in windows phone 7 app, have textblock followed checkbox. left right.

i doing programmatically, , can following code:

stackpanel controlstackpanel = new stackpanel(); controlstackpanel.orientation = system.windows.controls.orientation.horizontal;  textblock controltextblock = new textblock(); controltextblock.text = @"controlnamegoeshere";  checkbox controlcheckbox = new checkbox(); controlcheckbox.margin = new thickness(0, 0, 0, 0); controlcheckbox.horizontalalignment = system.windows.horizontalalignment.right;  controlstackpanel.children.add(controltextblock); controlstackpanel.children.add(controlcheckbox); 

however, i textblock element align left side of screen, , checkbox element align right side of screen. how can this?

do need add grid programmatically? reason don't want in xaml adding these stackpanels going iterative process, , works better code if programmatically.

i've googled heck of lot, haven't had luck.

many thanks! brett

a content control has 1 alignment @ once. controls within aligned according it's horizontal alignment. may wish have 2 content controls different alignments inside larger outer container.

grid   stackpanel left      control   stackpanel right      control 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -