Silverlight – Windows Phone 7 Application – Direction Change

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!

What about the default portrait configuration: –

< /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);
}

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);
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4027 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.