如何使用全景项的SelectionChanged [英] how to use panorama item selectionchanged

查看:129
本文介绍了如何使用全景项的SelectionChanged的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图来检测当前全景项,用户目前对,然后相应地切换应用程序栏图标按钮IsEnabled属性。我还没有就如何实现一个特性就是这样,或者正确地检测当前全景项的任何运气。具体来说,我想用selectedItem属性和检测全景物品,而不是selectedIndex属性的名称,因为全景项可能改变它们的顺序。有没有办法做到这一点?到目前为止,我有什么如下:

I am attempting to detect the current panorama item that a user is currently on and then toggle an application bar icon button isenabled property accordingly. I have not had any luck on how to implement a feature like this, or properly detect the current panorama item. Specifically, I would like to use the selectedItem property and detect the name of the panorama items instead of the selectedIndex property because the panorama items may change their order. Is there any way to do this? So far what I have is the following:

MainPage.xaml中

MainPage.xaml

<controls:Panorama SelectionChanged="PanoramaItemSelectionChanged">         

            <!--Panorama item one-->
            <controls:PanoramaItem Header="statuses" >
                ...
            </controls:PanoramaItem>

            <!--Panorama item two-->
            <controls:PanoramaItem Header="mentions" >
                ...
            </controls:PanoramaItem>

            <!--Panorama item three-->
            <controls:PanoramaItem Header="messages" >
                ...
            </controls:PanoramaItem>

            <!--Panorama item four-->
            <controls:PanoramaItem Header="favorites" >
                ...
            </controls:PanoramaItem>

        </controls:Panorama> 



MainPage.xaml.cs中

MainPage.xaml.cs

private void PanoramaItemSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        string currentPanoramaItem = e.AddedItems[0] as string;

        switch (currentPanoramaItem)
        {
            case "statuses":
                //show application bar button?
                break;
            case "mentions":
                //show application bar button?
                break;
            case "messages":
                ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
                break;
            case "favorites":
                //show application bar button?
                break;
            default:
                return;
        }            
    }



我的SelectionChanged实现不会出于某种原因。 ?任何想法(用一个例子请)

my SelectionChanged implementation does not work for some reason. Any ideas (with an example please)?

推荐答案

在switch语句中使用的panoramaItemSelectionChanged字符串值应为以下内容:

The panoramaItemSelectionChanged string value used in the switch statement should be the following:

string currentPanoramaItem = ((PanoramaItem)(((Panorama)sender).SelectedItem)).Header.ToString();

这篇关于如何使用全景项的SelectionChanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆