[英]Windows phone create side menu bar like Facebook
我是Windows Phone 7開發的新手,我正在嘗試創建像Facebook上使用的那樣的側面菜單欄。
我創建了usercontrol
並為不同的屏幕添加了按鈕,我還創建了PhoneApplicationPage
並添加了一個按鈕。
當我點擊該按鈕時,它會嘗試像菜單欄一樣從上到下滑動。
如果我再次點擊它,在右上角的按鈕會隱藏它。
如果有人可以提供幫助,請分享您的代碼或示例。
謝謝。
我剛剛為此寫了一個完整的解決方案......確實你需要視覺狀態! http://depblog.weblogs.us/2013/07/22/facebook-like-settings-pane-windows-phone/
看看SlideView
,被描述為“...導航抽屜的靈感來自Windows Phone上的官方Facebook應用程序。” https://slideview.codeplex.com/
編輯一旦您通過nuget的安裝包SlideView安裝了SlideView
創建一個代表您想要的SlideView的UserControl,比如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在我啟動它時崩潰了。 但是當我使用Zumicts Fork of SlideView時,一切都有效,這里有一個nuget包
Install-Package SlideView.Library.WP81.Zumicts
有沒有人遇到過同樣的問題?
那么就像iOS一樣,沒有一種簡單的方法可以做到這一點。 但您可以使用Visual State Manager 。
基本上,塑造比你的舞台更大的屏幕。 然后,您需要創建一個狀態,在屏幕中稍微移動屏幕,您可以使用按鈕。 你需要在點擊方法的按鈕上調用狀態。
PS:不要使用故事板。 使用狀態這是最簡單的方法。
嘗試像Facebook一樣的側面菜單欄也有手勢支持。 嘗試下面的鏈接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.