I am developing a Windows Phone 7 application and I cannot figure out what I think is a simple question for experienced people.
Suppose I have a layout consisting of two elements: a ListBox (Filled with a lot of items) and a TextBlock (to provide users with some basic instructions).
When the device is in portrait orientation, I want these to be one on top of the other, and when the device is oriented When changing to landscape, I want them to be next to each other.
For portrait orientation, I use the grid layout manager because it allows me to define the height of the row, so… row 0 height = “2 *” , Line 1 height = “*”
Listbox is on line 0 and TextBlock is on line 1. Now, what is really concise is to simply change RowDefinitions to ColumnDefinitions and reassign the list box/text block to The columns of the grid instead of the rows when the device is switched to Landscape.
But this is just my idea. I don’t know how to do this elegantly. Maybe there is a better way? Or maybe this is the right way, and there are some methods built just for this purpose?
Thank you for your suggestion!
< /p>
< /Grid.RowDefintions>
Content
Then use it in your OrientationChanged event: –
if ((e.Orientation & PageOrientation.Portrait) == PageOrientation.Portrait)
{
Grid.SetRow(ItemList, 0);
Grid.SetRowSpan(ItemList, 1);
Grid.SetColumn(ItemList, 0);
Grid.SetColumnSpan(ItemList, 2);
Grid.SetRow(Instructions, 1);
Grid.SetRowSpan(Instructions, 1);
Grid.S etColumn(Instructions, 0);
Grid.SetColumnSpan(Instructions, 2);
}
else
{
Grid.SetRow(ItemList, 0);
Grid.SetRowSpan(ItemList, 2);
Grid.SetColumn(ItemList, 0);
Grid.SetColumnSpan(ItemList, 1);
Grid.SetRow(Instructions , 0);
Grid.SetRowSpan(Instructions, 2);
Grid.SetColumn(Instructions, 1);
Grid.SetColumnSpan(Instructions, 1);
} pre>
Hello developers!
I am developing a Windows Phone 7 application and I cannot figure out what I think is a simple question for experienced people.
Suppose I have a layout consisting of two elements: a ListBox (Filled with a lot of items) and a TextBlock (to provide users with some basic instructions).
When the device is in portrait orientation, I want these to be one on top of the other, and when the device is oriented When changing to landscape, I want them to be next to each other.
For portrait orientation, I use the grid layout manager because it allows me to define the height of the row, so... row 0 height = "2 *" , Line 1 height = "*"
Listbox is on line 0 and TextBlock is on line 1. Now, what is really concise is to simply change RowDefinitions to ColumnDefinitions and reassign the list box/text block to The columns of the grid instead of the rows when the device is switched to Landscape.
But this is just my idea. I don't know how to do this elegantly. Maybe there is a better way? Or maybe this is the right way, and there are some methods built just for this purpose?
Thank you for your suggestion!
How about the default vertical configuration: –
Content
Then use it in your OrientationChanged event: –
if ((e.Orientation & PageOrientation.Portrait) == PageOrientation.Portrait)
{
Grid.SetRow(ItemList, 0);
Grid.SetRowSpan(ItemList, 1);
Grid.SetColumn(ItemList, 0);
Grid.SetColumnSpan(ItemList, 2);
Grid.SetRow(Instructions, 1);
Grid.SetRowSpan(Instructions, 1);
Grid.SetColumn(Instructions , 0);
Grid.SetColumnSpan( Instructions, 2);
}
else
{
Grid.SetRow(ItemList, 0);
Grid.SetRowSpan(ItemList, 2);
Grid.SetColumn(ItemList, 0);
Grid.SetColumnSpan(ItemList, 1);
Grid.SetRow(Instructions, 0);
Grid.SetRowSpan(Instructions, 2 );
Grid.SetColumn(Instructions, 1);
Grid.SetColumnSpan(Instructions, 1);
}