Q: How to use Master Detail Page in Xamarin Forms.
3. Create a MenuPage like below
public class MenuPage : ContentPage
{
public ListView Menu { get; set; }
public MenuPage()
{
Icon = "settings.png";
Title = "Menu"; // The Title property must be set.
BackgroundColor = Color.FromHex("333333");
Menu = new MenuListView();
var layout = new StackLayout
{
Spacing = 0,
VerticalOptions = LayoutOptions.FillAndExpand
};
layout.Children.Add(Menu);
Content = layout;
}
}
4. Create the "ManuItem" class, like below
public class MenuItem {
public string Title { get; set; }
public string IconSource { get; set; }
public Type TargetType { get; set; }
}
5. Create a class inheritance listview, like below
public class MenuListView : ListView
{
public MenuListView()
{
List<MenuItem> data = new MenuListData();
ItemsSource = data;
VerticalOptions = LayoutOptions.FillAndExpand;
BackgroundColor = Color.Transparent;
var cell = new DataTemplate(typeof(ImageCell));
cell.SetBinding(TextCell.TextProperty, "Title");
cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource");
ItemTemplate = cell;
//SelectedItem = data[0];
}
}
public class MenuListData : List<MenuItem>
{
public MenuListData()
{
this.Add(new MenuItem()
{
Title = "Home",
TargetType = typeof(HomePage)
});
this.Add(new MenuItem()
{
Title = "About Us",
TargetType = typeof(AboutUsPage)
});
}
}
6. Create the content pages according to your requirement.
public class HomePage : ContentPage
{
public HomePage()
{
BackgroundColor = Color.Yellow;
Title = "Home Page";
Content = new Label
{
Text = "Home Page!",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
};
}
}
public class AboutUsPage : ContentPage
{
public AboutUsPage()
{
BackgroundColor = Color.Green;
Title = "AboutUs Page";
Content = new Label
{
Text = "About Us Page!",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
};
}
}
7. Output
Ans:
1. Create a Mobile Project using "Visual Studio" or "Xamarin Studio".
2. Create a page in shared section and type the code below.
public class MainPage : MasterDetailPage
{
public MainPage()
{
var menuPage = new MenuPage();
menuPage.Menu.ItemSelected += (sender, e) => NavigateToPage(e.SelectedItem as MenuItem);
Master = menuPage;
Detail = new NavigationPage(new HomePage());
}
void NavigateToPage(MenuItem menu)
{
Page displayPage = (Page)Activator.CreateInstance(menu.TargetType);
Detail = new NavigationPage(displayPage);
IsPresented = false;
}
}
public class MenuPage : ContentPage
{
public ListView Menu { get; set; }
public MenuPage()
{
Icon = "settings.png";
Title = "Menu"; // The Title property must be set.
BackgroundColor = Color.FromHex("333333");
Menu = new MenuListView();
var layout = new StackLayout
{
Spacing = 0,
VerticalOptions = LayoutOptions.FillAndExpand
};
layout.Children.Add(Menu);
Content = layout;
}
}
4. Create the "ManuItem" class, like below
public class MenuItem {
public string Title { get; set; }
public string IconSource { get; set; }
public Type TargetType { get; set; }
}
5. Create a class inheritance listview, like below
public class MenuListView : ListView
{
public MenuListView()
{
List<MenuItem> data = new MenuListData();
ItemsSource = data;
VerticalOptions = LayoutOptions.FillAndExpand;
BackgroundColor = Color.Transparent;
var cell = new DataTemplate(typeof(ImageCell));
cell.SetBinding(TextCell.TextProperty, "Title");
cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource");
ItemTemplate = cell;
//SelectedItem = data[0];
}
}
public class MenuListData : List<MenuItem>
{
public MenuListData()
{
this.Add(new MenuItem()
{
Title = "Home",
TargetType = typeof(HomePage)
});
this.Add(new MenuItem()
{
Title = "About Us",
TargetType = typeof(AboutUsPage)
});
}
}
6. Create the content pages according to your requirement.
public class HomePage : ContentPage
{
public HomePage()
{
BackgroundColor = Color.Yellow;
Title = "Home Page";
Content = new Label
{
Text = "Home Page!",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
};
}
}
public class AboutUsPage : ContentPage
{
public AboutUsPage()
{
BackgroundColor = Color.Green;
Title = "AboutUs Page";
Content = new Label
{
Text = "About Us Page!",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
};
}
}
7. Output
This is probably the best, most concise step-by guide on How to use Master Detail Page in Xamarin Forms.
ReplyDeleteHire Xamarin Developer now to develop your Xamarin Apps.
I am really happy with your blog because your article is very unique and powerful for new reader.
ReplyDeleteselenium training in chennai
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
ReplyDeleterpa Training in annanagar
blue prism Training in annanagar
automation anywhere Training in annanagar
iot Training in annanagar
rpa Training in marathahalli
blue prism Training in marathahalli
automation anywhere Training in marathahalli
blue prism training in jayanagar
automation anywhere training in jayanagar
Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up.
ReplyDeleteData Science Training in Chennai
Data science training in bangalore
Data science online training
Data science training in pune
Data science training in kalyan nagar
selenium training in chennai
Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
ReplyDeletejava training in chennai | java training in bangalore
java online training | java training in pune
java training in chennai | java training in bangalore
I appreciate that you produced this wonderful article to help us get more knowledge about this topic. I know, it is not an easy task to write such a big article in one day, I've tried that and I've failed. But, here you are, trying the big task and finishing it off and getting good comments and ratings. That is one hell of a job done!
ReplyDeletepython training in pune
python online training
python training in OMR
I love the blog. Great post. It is very true, people must learn how to learn before they can learn. lol i know it sounds funny but its very true. . .
ReplyDeleteBlueprism training institute in Chennai
Blueprism online training
Blue Prism Training Course in Pune
Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
ReplyDeleteangularjs Training in chennai
angularjs-Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
angularjs-Training in sholinganallur
Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeleteAWS Interview Questions And Answers
AWS Training in Bangalore | Amazon Web Services Training in Bangalore
AWS Training in Pune | Best Amazon Web Services Training in Pune
Amazon Web Services Training in Pune | Best AWS Training in Pune
AWS Online Training | Online AWS Certification Course - Gangboard
Anyhow I am here now and would just like to say thanks a lot for a tremendous post and an all-round exciting blog
ReplyDeletesafety course in chennai
I am really very happy to find this particular site. I just wanted to say thank you for this huge read!! I absolutely enjoying every petite bit of it and I have you bookmarked to test out new substance you post.
ReplyDeletedevops online training
aws online training
data science with python online training
data science online training
rpa online training
The way of you expressing your ideas is really good.you gave more useful ideas for us and please update more ideas for the learners.
ReplyDeleteHadoop Training in Chennai
Big data training in chennai
big data training in velachery
JAVA Training in Chennai
Python Training in Chennai
Software testing training in chennai
Hadoop training in chennai
Big data training in chennai
big data training in chennai anna nagar
Great and Nice Blog! I would like to thank for the efforts you have made in writing this great article. Thanks for sharing.
ReplyDeleteData Science Courses
Amazing knowledge and I like to share this kind of information with my friends and hope they like it they why I do
ReplyDeleteData Science Course in Pune
This comment has been removed by the author.
ReplyDeleteA debt of gratitude is in order for sharing the information, keep doing awesome... I truly delighted in investigating your site. great asset...
ReplyDeleterpa training in malaysia
Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!
ReplyDeletemobile application development course | mobile app development training | mobile application development training online
"web designing classes in chennai | Web Designing courses in Chennai "
Web Designing Training and Placement | Best Institute for Web Designing
Web Designing and Development Course | Web Designing Training in Chennai
mobile application development course | mobile app development training
mobile application development training online | mobile app development course
mobile application development course | learn mobile application development
app development training | mobile application development training
mobile app development course online | online mobile application development.
website design course | Web designing course in Chennai
ReplyDeleteclick here formore info.
ReplyDeleteAn outstanding share! I have just forwarded this onto a colleague who had been doing a little research on this. And he actually bought me dinner because I found it for him... lol. So let me reword this.... Thank YOU for the meal!! But yeah, thanks for spending time to talk about this matter here on your blog.
ReplyDelete
ReplyDeleteGreat information. Thank you for sharing
Machine Learning Course Training In Hyderabad
Hi, Thanks for sharing beautiful content...
ReplyDeleteAi Training In Hyderabad
Thanks for Posting. Really the Blog is very Impressive.
ReplyDeleteData Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery
I know that it takes a lot of effort and hard work to write such an informative content like this
ReplyDeleteSalesforce Training | Online Course | Certification in chennai | Salesforce Training | Online Course | Certification in bangalore | Salesforce Training | Online Course | Certification in hyderabad | Salesforce Training | Online Course | Certification in pune
I'm here representing the visitors and readers of your own website say many thanks for many remarkable.thanks a lot guys.
ReplyDeleteAi & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
ReplyDeleteThanks For Sharing The Information With Us.
AWS Training in Hyderabad
AWS Course in Hyderabad
wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
ReplyDeletePMP Certification
wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries. keep it up.
ReplyDeleteData Science Course in Pune
Excellent Blog! I would like to thank for the efforts you have made in writing this post.
ReplyDeleteBusiness Analytics Course
I appreciate this article. Is very nice content. thanking you
ReplyDeletePython Training in Chennai
Python Training in Bangalore
Python Training in Hyderabad
Python Training in Coimbatore
Python Training
python online training
python flask training
python flask online training
Very interesting blog. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome.You can also check my articles as well. Data Science Training In Chennai | Certification | Data Science Courses in Chennai | Data Science Training In Bangalore | Certification | Data Science Courses in Bangalore | Data Science Training In Hyderabad | Certification | Data Science Courses in hyderabad | Data Science Training In Coimbatore | Certification | Data Science Courses in Coimbatore | Data Science Training | Certification | Data Science Online Training Course
ReplyDeleteGreat post i must say and thanks for the information.
ReplyDeleteData Analytics Courses
Great post i must say and thanks for the information.
ReplyDeleteData Scientist Course
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog of salesforce developer training . Really very informative post you shared here. Kindly keep blogging...
ReplyDeletesap training in chennai
sap training in tambaram
azure training in chennai
azure training in tambaram
cyber security course in chennai
cyber security course in tambaram
ethical hacking course in chennai
ethical hacking course in tambaram
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind...
ReplyDeleteangular js training in chennai
angular js training in omr
full stack training in chennai
full stack training in omr
php training in chennai
php training in omr
photoshop training in chennai
photoshop training in omr
I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts.
ReplyDeletea href="https://www.excelr.com/data-analytics-certification-training-course-in-pune/"> Data Analytics Course in Pune/">Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.
I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging. After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
ReplyDeleteTableau Online Training
I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts.
ReplyDeleteData Analytics Course in PuneWow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.
I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
Attend The Business Analytics Courses From ExcelR. Practical Business Analytics Courses Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Business Analytics Courses.
ReplyDeleteBusiness Analytics Courses
Cool stuff you have and you keep overhaul every one of us
ReplyDeletepmp certification in bangalore
Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Visit here for Penetration testing services and Software testing services
ReplyDeleteI have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it..
ReplyDeletedata science online training in hyderabad
Tül perde modelleri
ReplyDeleteMOBİL ONAY
Mobil odeme bozdurma
nftnasilalinir.com
ankara evden eve nakliyat
trafik sigortası
dedektör
Kurma websitesi
aşk kitapları
Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.
ReplyDeletefull stack web development course in malaysia
A debt of gratitude is in order for sharing the information, keep doing awesome... I truly delighted in investigating your site. great asset...
ReplyDeleteonline grocery delivery
hivasu.online
ReplyDeleteThank you for your valuable answer. Want to know more about Data Science Course In Jaipur
ReplyDelete