mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-22 15:39:19 +00:00
Organize Views
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="qController.RootPage" xmlns:pages="clr-namespace:qController">
|
||||
|
||||
</MasterDetailPage>
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace qController
|
||||
{
|
||||
public class MenuEventArgs : EventArgs
|
||||
{
|
||||
public string Command
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class RootPage : MasterDetailPage
|
||||
{
|
||||
public MenuPage MenuPage;
|
||||
public delegate void MenuItemSelectedHandler(object source, MenuEventArgs args);
|
||||
public event MenuItemSelectedHandler MenuItemSelected;
|
||||
|
||||
public RootPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
MenuPage = (MenuPage)Master;
|
||||
|
||||
MenuPage.setItemSelected(OnItemSelected);
|
||||
}
|
||||
|
||||
void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
var item = e.SelectedItem as MenuPageItem;
|
||||
if (item != null)
|
||||
{
|
||||
MenuPage.clearSelectedItem();
|
||||
IsPresented = false;
|
||||
if (MenuItemSelected != null)
|
||||
MenuItemSelected(this, new MenuEventArgs { Command = item.Command });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?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="qController.Pages.RootPageDetail" 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." />
|
||||
</StackLayout>
|
||||
</ContentPage>
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace qController.Pages
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class RootPageDetail : ContentPage
|
||||
{
|
||||
public RootPageDetail()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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="qController.Pages.RootPageMaster" Title="Master">
|
||||
<StackLayout>
|
||||
<ListView x:Name="MenuItemsListView" SeparatorVisibility="None" HasUnevenRows="true" ItemsSource="{Binding MenuItems}">
|
||||
<ListView.Header>
|
||||
<Grid BackgroundColor="#03A9F4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="10" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Column="1" Grid.Row="2" Text="AppName" Style="{DynamicResource SubtitleStyle}" />
|
||||
</Grid>
|
||||
</ListView.Header>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<StackLayout Padding="15,10" HorizontalOptions="FillAndExpand">
|
||||
<Label VerticalOptions="FillAndExpand" VerticalTextAlignment="Center" Text="{Binding Title}" FontSize="24" />
|
||||
</StackLayout>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</StackLayout>
|
||||
</ContentPage>
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace qController.Pages
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class RootPageMaster : ContentPage
|
||||
{
|
||||
public ListView ListView;
|
||||
|
||||
public RootPageMaster()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
BindingContext = new RootPageMasterViewModel();
|
||||
ListView = MenuItemsListView;
|
||||
}
|
||||
|
||||
class RootPageMasterViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public ObservableCollection<RootPageMenuItem> MenuItems { get; set; }
|
||||
|
||||
public RootPageMasterViewModel()
|
||||
{
|
||||
MenuItems = new ObservableCollection<RootPageMenuItem>(new[]
|
||||
{
|
||||
new RootPageMenuItem { Id = 0, Title = "Page 1" },
|
||||
new RootPageMenuItem { Id = 1, Title = "Page 2" },
|
||||
new RootPageMenuItem { Id = 2, Title = "Page 3" },
|
||||
new RootPageMenuItem { Id = 3, Title = "Page 4" },
|
||||
new RootPageMenuItem { Id = 4, Title = "Page 5" },
|
||||
});
|
||||
}
|
||||
|
||||
#region INotifyPropertyChanged Implementation
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
if (PropertyChanged == null)
|
||||
return;
|
||||
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user