Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
renaming files, for better understanding
Browse files Browse the repository at this point in the history
  • Loading branch information
wojta committed Mar 15, 2018
1 parent 8308974 commit b528aff
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
12 changes: 9 additions & 3 deletions Example/Example/Example.csproj
Expand Up @@ -26,12 +26,18 @@
<Compile Update="Views\Pages\HttpPage.xaml.cs">
<DependentUpon>HttpPage.xaml</DependentUpon>
</Compile>
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="Views\DrawerMenuPage.cs">
<DependentUpon>DrawerMenuPage.xaml</DependentUpon>
</Compile>
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="Views\RootPageMaster.xaml.cs">
<DependentUpon>DrawerMenuPage.xaml</DependentUpon>
</Compile>
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="Views\DrawerMenuPage.xaml.cs">
<DependentUpon>DrawerMenuPage.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Views\RootPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\RootPageMaster.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Expand Down
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Example.Views.RootPageMaster"
x:Class="Example.Views.DrawerMenuPage"
Title="Master">
<StackLayout>
<ListView x:Name="MenuItemsListView"
Expand Down
Expand Up @@ -14,11 +14,11 @@
namespace Example.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class RootPageMaster : ContentPage
public partial class DrawerMenuPage : ContentPage
{
public ListView ListView;

public RootPageMaster()
public DrawerMenuPage()
{
InitializeComponent();

Expand All @@ -28,14 +28,14 @@ public RootPageMaster()

class RootPageMasterViewModel : INotifyPropertyChanged
{
public ObservableCollection<RootPageMenuItem> MenuItems { get; set; }
public ObservableCollection<MenuItem> MenuItems { get; set; }

public RootPageMasterViewModel()
{
MenuItems = new ObservableCollection<RootPageMenuItem>(new[]
MenuItems = new ObservableCollection<MenuItem>(new[]
{
new RootPageMenuItem { Id = 0, Title = StringResources.NavHome, TargetType=typeof(HomePage) },
new RootPageMenuItem { Id = 1, Title = StringResources.NavHttp, TargetType=typeof(HttpPage) },
new MenuItem { Id = 0, Title = StringResources.NavHome, TargetType=typeof(HomePage) },
new MenuItem { Id = 1, Title = StringResources.NavHttp, TargetType=typeof(HttpPage) },
});
}

Expand Down
Expand Up @@ -6,10 +6,9 @@

namespace Example.Views
{

public class RootPageMenuItem
public class MenuItem
{
public RootPageMenuItem()
public MenuItem()
{
TargetType = typeof(Pages.HomePage);
}
Expand Down
3 changes: 2 additions & 1 deletion Example/Example/Views/Pages/HomePage.xaml
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- this page is displayed on start as first page -->
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Example.Views.Pages.HomePage"
Title="Detail">
<StackLayout Padding="10">
<Label Text="This is a detail page. To get the 'triple' line icon on each platform add a icon to each platform and update the 'Master' page with an Icon that references it."/>
<Label Text="Welcome to AeroGear Xamarin Example!"/>
</StackLayout>
</ContentPage>
2 changes: 1 addition & 1 deletion Example/Example/Views/RootPage.xaml
Expand Up @@ -5,7 +5,7 @@
xmlns:masterpages="clr-namespace:Example.Views"
xmlns:pages="clr-namespace:Example.Views.Pages">
<MasterDetailPage.Master>
<masterpages:RootPageMaster x:Name="MasterPage" />
<masterpages:DrawerMenuPage x:Name="DrawerMenuPage" />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
Expand Down
9 changes: 6 additions & 3 deletions Example/Example/Views/RootPage.xaml.cs
Expand Up @@ -15,12 +15,15 @@ public partial class RootPage : MasterDetailPage
public RootPage()
{
InitializeComponent();
MasterPage.ListView.ItemSelected += ListView_ItemSelected;
DrawerMenuPage.ListView.ItemSelected += ListView_ItemSelected;
}

/// <summary>
/// Replaces page when item is selected in the drawer menu.
/// </summary>
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = e.SelectedItem as RootPageMenuItem;
var item = e.SelectedItem as MenuItem;
if (item == null)
return;

Expand All @@ -30,7 +33,7 @@ private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e
Detail = new NavigationPage(page);
IsPresented = false;

MasterPage.ListView.SelectedItem = null;
DrawerMenuPage.ListView.SelectedItem = null;
}
}
}

0 comments on commit b528aff

Please sign in to comment.