Display issue while add control Programmatically in WP7 using Visual studio 2010
I have Created Mobile Application Using Visual Studio 2010 C#. There i have created one button Prog开发者_Python百科rammatically and Add that button into Contentpanel .While running my app i got Button display successfully. But it has Following issue -that Button Always Display Center of the Content panel even i have metion the thickness as(0,0,80,80)
-I have tried to add that button into Layoutroot , Button Display better in Y postion But X position center of the Layoutroot
Here i have enclosed my code for ur reference
Button nw = new Button();
nw.Margin = new Thickness(0, 0, 80, 150);
ContentPanel.Children.Add(nw);
Try this?
Button nw = new Button();
nw.VerticalAlignment = System.Windows.VerticalAlignment.Top;
nw.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
nw.Margin = new Thickness(80, 150, 0, 0);
ContentPanel.Children.Add(nw);
This depends on what else is also in ContentPanel
- which I assume is the grid from the default template.
If there is nothing else in it then it will take up the whole space occupied by the grid, minus the space you have allocated to the margin.
Please provide a complete example which demonstrates the behaviour you are seeing and tell us what you are trying to achieve. (How do you want the button to be displayed?)
精彩评论