6

我是 Windows Phone 7 开发的新手,我正在尝试创建类似于 Facebook 上使用的侧菜单栏。

我已经usercontrol为不同的屏幕创建并添加了按钮,我还创建PhoneApplicationPage并添加了一个按钮。

当我单击该按钮时,它将尝试像菜单栏一样从上到右滑动。

如果我再次单击它,它会在右上角隐藏它。

如果有人可以提供帮助,请分享您的代码或示例。

谢谢。

4

4 回答 4

9

我刚刚为此写了一个完整的解决方案……确实你需要视觉状态! http://depblog.weblogs.us/2013/07/22/facebook-like-settings-pane-windows-phone/

于 2013-07-23T06:55:50.743 回答
1

签出SlideView,被描述为“......灵感来自 Windows Phone 上的官方 Facebook 应用程序的导航抽屉。” https://slideview.codeplex.com/

编辑一旦你通过 nuget 的安装包 SlideView 安装了 SlideView

创建一个用户控件,它将代表您想要的 SlideView,例如 LeftView.xaml。您可以为另一方创建另一个用户控件,例如 RightView.xaml

然后在您的 App.xaml 文件中,将 SlideView 定义为资源,

xmlns:slideView="using:SlideView.Library"
xmlns:views="using:SideNav.Views"
xmlns:local="using:SideNav">

<Application.Resources>
    <slideView:SlideApplicationFrame Header="SlideView" Background="White" x:Key="RootFrame" >
        <slideView:SlideApplicationFrame.LeftContent>
            <views:LeftView/>
        </slideView:SlideApplicationFrame.LeftContent>
        <slideView:SlideApplicationFrame.RightContent>
            <views:RightView/>
        </slideView:SlideApplicationFrame.RightContent>
    </slideView:SlideApplicationFrame>
</Application.Resources>

完成后编辑您的 App.xaml.cs 以更改默认的 RootFrame 和 OnLaunchedMethod

public sealed partial class App : Application
{
    private TransitionCollection transitions;

    public static SlideApplicationFrame RootFrame { get; private set; }

    protected override void OnLaunched(LaunchActivatedEventArgs e)
    {

        RootFrame = Window.Current.Content as SlideApplicationFrame;

        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (RootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            RootFrame = this.Resources["RootFrame"] as SlideApplicationFrame;

            // TODO: change this value to a cache size that is appropriate for your application
            RootFrame.CacheSize = 1;

            // Set the default language
            RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

            if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                // TODO: Load state from previously suspended application
            }

            // Place the frame in the current Window
            Window.Current.Content = RootFrame;
        }

        if (RootFrame.Content == null)
        {
            // Removes the turnstile navigation for startup.
            if (RootFrame.ContentTransitions != null)
            {
                this.transitions = new TransitionCollection();
                foreach (var c in RootFrame.ContentTransitions)
                {
                    this.transitions.Add(c);
                }
            }

            RootFrame.ContentTransitions = null;
            RootFrame.Navigated += this.RootFrame_FirstNavigated;

            // When the navigation stack isn't restored navigate to the first page,
            // configuring the new page by passing required information as a navigation
            // parameter
            if (!RootFrame.Navigate(typeof(MainPage), e.Arguments))
            {
                throw new Exception("Failed to create initial page");
            }
        }

        // Ensure the current window is active
        Window.Current.Activate();
    }
}

这应该可以工作。只需将内容添加到 Rightview.xaml 和 LeftView.xaml。出于某种原因,当我启动它时,我的 WindowsPhone 8.1 xaml 崩溃了。但是当我使用 SlideView 的 Zumicts Fork 时一切正常,它可以作为 nuget 包在这里

Install-Package SlideView.Library.WP81.Zumicts

有没有人遇到过同样的问题?

于 2014-12-28T13:14:01.760 回答
0

尝试像 facebook 这样的侧面菜单栏也支持手势。试试下面的链接。

http://developer.nokia.com/community/wiki/Control_animation_while_navigating_between_panes_inside_a_Windows_Phone_page

于 2014-11-03T20:46:37.187 回答
0

好吧,没有像 iOS 那样简单的方法来做到这一点。但是您可以使用Visual State Manager

基本上,塑造比您的舞台更大的屏幕。然后,您需要创建一个状态,将您的屏幕在舞台上向左移动一点,您可以使用一个按钮。您需要在按钮的单击方法上调用状态。

PS:不要使用情节提要。使用 States 是最简单的方法。

于 2013-04-13T07:50:27.173 回答