How to programmatically switch to a different PanoramaItem?
Note: I already saw this and it doesn't answer the question.
I have a first run experience for my app that presents the user with a few different options explaining what the app does. If they select one of those options, I want to show them the PanoramaItem
that deals with that particular functionality. It happens to be item #3.
So, Panorama.SelectedItem
is read-only. Is there some other way to do it? If not, could I fake it by, say, simulating some gesture input? How 开发者_如何学Cwould one do that?
Since SelectedItem
and SelectedIndex
are currently under the private set
rule, indeed you cannot modify them through the application. However, you can change the DefaultItem
property:
<PANORAMA_CONTROL>.DefaultItem = <PANORAMA_CONTROL>.Items[1];
It will cause items to be a bit re-arranged since you are setting an item to be the first in the list, but other than that it is an acceptable way to do this, since it will actually bring the item in front of the user.
You can change the DefaultItem.
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string selected = String.Empty;
//check to see if the selected parameter was passed.
if (NavigationContext.QueryString.ContainsKey("selected"))
{
//get the selected parameter off the query string from MainPage.
selected = NavigationContext.QueryString["selected"];
}
//did the querystring indicate we should go to item2 instead of item1?
if (selected == "item2")
{
//item2 is the second item, but 0 indexed.
myPanorama.DefaultItem = myPanorama.Items[1];
}
base.OnNavigatedTo(e);
}
Here's an example I made for a different purpose but it has this functionality. http://dl.dropbox.com/u/129101/Panorama_querystring.zip
精彩评论