I have two listBox ItemTemplate in the XAML.But i can't change it with the Page's orientationChanged event to change the DataTemplate. here is the code:
protected override void OnOrientationChanged(OrientationChangedEventArgs e)
{
if (e.Orientation == PageOrientation.Landscape ||
e.Orientation == PageOrientation.LandscapeLeft ||
e.Orientation == PageOrientation.LandscapeRight)
{
this.HeadLineListBox.ItemTemplate = (DataTemplate)this.Resources["L_headerTemplate"];
}
else if (e.Orientation == PageOrientation.Portrait ||
e.Orientation == PageOrientation.PortraitDown ||
e.Orientation == PageOrientation.PortraitUp)
{
this.HeadLineListBox.ItemTemplate = (DataTemplate)this.Resources["P_headerTemplate"];
}
base.OnOrientationChanged(e);
}
When i first into the page if the Orientation is Portrait, it will show the Portrait DataTemplate all the time even i changed the Orientation. So do when i first into the page it is Landscape.Someone can help me?
PS:I used the way post here:http://wp7-developer.com/code-snippet/changing-the-datatemplate-based-on-page-orientation/But it still don't work.