2016-04-03 3 views
0

私は(私のmasterdetailpageとして働く)menupageと私のcontentpageを持つrootpageを持っています。私は私のmenupageアイコン/テキストをクリックするとmenupage(mdp)がアイコン/テキストをクリックするとそのコンポーネントを初期化します。masterdetailpageアイコン/テキストでclickeventを作れますか?

可能ですか?

これは私が現在持っているコードです。

public RootPage() 
    { 
     NavigationPage.SetHasNavigationBar (this, false); 
     var theMenu = new MenuPage (this); 

     theMenu.Title = "Click"; 
     theMenu.Icon = "Icon-Small-40.png"; 

     //can I make a click with the theMenu.Title or Icon above? 

     Master = theMenu; 

     NavigationPage page = new NavigationPage(new StartPage()); 
     Detail = page; 

    } 

答えて

0

namespace LoginNavigation 
{ 
public class MenuListView : ListView 
{ 
public MenuListView() 
{ 
List<MenuItemForMaster> data = new MenuListData(); 

ItemsSource = data; 
VerticalOptions = LayoutOptions.FillAndExpand; 
BackgroundColor = Color.Accent; 

var cell = new DataTemplate (typeof(MenuCell)); 
//cell.SetBinding (MenuCell.TextProperty, "Title"); 
//cell.SetBinding (MenuCell.ImageSourceProperty, "IconSource"); 
this.HasUnevenRows = false; 
ItemTemplate = cell; 
} 

namespace LoginNavigation 
{ 
public class MenuListData : List<MenuItemForMaster> 
{ 
public MenuListData() 
{ 
this.Add (new MenuItemForMaster() { 
Name = “" 
ImageSource = "paper_plane.png", 
TargetType = typeof(TimeSheet) 
}); 
this.Add (new MenuItemForMaster() { 
Name = "Extn : 3969", 
ImageSource = "phone_reciever.png", 
TargetType = typeof(TimeSheet) 
}); 
this.Add (new MenuItemForMaster() { 
Name = "TimeSheet", 
ImageSource = "Calender.png", 
TargetType = typeof(TimeSheet) 
}); 

this.Add (new MenuItemForMaster() { 
Name = "Omega", 
ImageSource = "Notes.png", 
TargetType = typeof(Omega) 
}); 

} 
} 
} 
を次のようにコードの下にあなたMenuPageで

namespace LoginNavigation 
{ 
public class RootPage:MasterDetailPage 
{ 
MenuPage menuPage; 
public RootPage() 
{ 

menuPage = new MenuPage(); 

menuPage.Menu.ItemSelected += (sender, e) => NavigateTo (e.SelectedItem as MenuItemForMaster); 

Master = menuPage; 
Detail = new NavigationPage (new TimeSheet()){ 
}; 
} 

void NavigateTo (MenuItemForMaster menu) 
{ 
if (menu == null) 
return; 

Page displayPage = (Page)Activator.CreateInstance (menu.TargetType); 
//Detail = displayPage; 
Detail = new NavigationPage (displayPage) { BarBackgroundColor = Color.FromHex("008dce"),BackgroundColor = Color.FromHex("008dce")}; 

menuPage.Menu.SelectedItem = null; 
IsPresented = false; 
} 
} 
} 

を助けている場合、私は

Menu = new MenuListView(); 
Menu.RowHeight = 44; 
Menu.SeparatorColor = Color.FromHex ("e8e8e8"); 
Menu.SeparatorVisibility = SeparatorVisibility.Default; 

を持っmenuListViewとのDataClassがある私に教えてください

は最終的に、これはそれが動作するかどうか明日テストします、私は自分のコンピュータから今すぐだMenuItemForMaster

​​
+0

です! – medvedo

関連する問題