Pessoal estou utilizando o código abaixo para criar um menu Master Detail em Xamarin. O Código funciona perfeitamente em Android mas em Windows Phone ele tem um bug que não estou conseguindo resolver.
MainPage.cs
using AppNewsPlay.MenuItems;
using AppNewsPlay.Views;
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace AppNewsPlay
{
public partial class MainPage : MasterDetailPage
{
public List<MasterPageItem> menuList { get; set; }
public MainPage()
{
InitializeComponent();
menuList = new List<MasterPageItem>();
// setando os icones e passando parametros para as paginas
var page1 = new MasterPageItem() { Title = "Home", Icon = "ic_home_black_24dp.png", TargetType = typeof(Home) };
var page2 = new MasterPageItem() { Title = "Xbox", Icon = "ic_dashboard_black_24dp.png", TargetType = typeof(Xbox) };
var page3 = new MasterPageItem() { Title = "Playstation", Icon = "ic_games_black_24dp.png", TargetType = typeof(Playstation) };
var page4 = new MasterPageItem() { Title = "Jogos", Icon = "ic_videogame_asset_black_24dp.png", TargetType = typeof(Jogos) };
var page5 = new MasterPageItem() { Title = "Nintendo", Icon = "ic_phonelink_black_24dp.png", TargetType = typeof(Nintendo) };
var page6 = new MasterPageItem() { Title = "Artigos", Icon = "ic_description_black_24dp.png", TargetType = typeof(Artigos) };
var page7 = new MasterPageItem() { Title = "Sobre", Icon = "ic_info_black_24dp.png", TargetType = typeof(Sobre) };
var page8 = new MasterPageItem() { Title = "Contato", Icon = "ic_perm_contact_calendar_black_24dp.png", TargetType = typeof(Contato) };
//Adicionando Itens ao menu
menuList.Add(page1);
menuList.Add(page2);
menuList.Add(page3);
menuList.Add(page4);
menuList.Add(page5);
menuList.Add(page6);
menuList.Add(page7);
menuList.Add(page8);
//Adicionando os itens ao ListView na MainPage.xaml
navigationDrawerList.ItemsSource = menuList;
// Criando a Instancia da Pagina Inicial na Pagina Home
Detail = new NavigationPage((Page)Activator.CreateInstance(typeof(Home))) { BarBackgroundColor = Color.FromHex("#000000"), BarTextColor = Color.White };
// criando o bind para repassar a lista
this.BindingContext = new
{
Header = "",
Image = "novo_logo_40dpi_newsplay.png",
// Rodape
Footer = ""
};
// desabilitando o indicador de carregamento
waitActivityIndicator.IsRunning = false;
// ocultando a barra
waitActivityIndicator.IsVisible = false;
}
// função para o click do botão na lista
private void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = (MasterPageItem)e.SelectedItem;
Type page = item.TargetType;
Detail = new NavigationPage((Page)Activator.CreateInstance(page)) { BarBackgroundColor = Color.FromHex("#000000"), BarTextColor = Color.White };
IsPresented = false;
}
protected override bool OnBackButtonPressed()
{
base.OnBackButtonPressed();
return true;
}
}
}
Quando eu clico em uma noticia e depois clico no botão voltar o Windows Phone simplesmente deixa de exibir o menu Hamburger, exibindo somente o conteudo da tela sem o menu, sugestões de como resolver?
veja imagens
Para chamar a proxima tela eu uso o seguinte código.
// Função que retorna o item selecionado da aba Ultimas Noticias
private async void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
if(e.SelectedItem !=null)
{
var selection = e.SelectedItem as UltimasNoticias;
var PostView = new PostView(selection.Id);
await Navigation.PushAsync(PostView, true);
#region DisabledSelectionHighlighting
((ListView)sender).SelectedItem = null;
#endregion
}
}