simple register page using tableview

main
syneffort 2 years ago
parent 5090cfa72f
commit ed06dce489
  1. 4
      XamarinStudy/XamarinStudy/XamarinStudy/App.xaml.cs
  2. 11
      XamarinStudy/XamarinStudy/XamarinStudy/CustomViewCells/CustomViewCell1.xaml
  3. 35
      XamarinStudy/XamarinStudy/XamarinStudy/CustomViewCells/CustomViewCell1.xaml.cs
  4. 17
      XamarinStudy/XamarinStudy/XamarinStudy/CustomViewCells/JobSelector.xaml
  5. 31
      XamarinStudy/XamarinStudy/XamarinStudy/CustomViewCells/JobSelector.xaml.cs
  6. 42
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleTableViewSimpleRegisterPage.xaml
  7. 44
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleTableViewSimpleRegisterPage.xaml.cs
  8. 9
      XamarinStudy/XamarinStudy/XamarinStudy/XamarinStudy.csproj

@ -51,7 +51,9 @@ namespace XamarinStudy
//MainPage = new SampleDisplayAlertActionSheetPage();
MainPage = new SampleTableViewPage();
//MainPage = new SampleTableViewPage();
MainPage = new NavigationPage(new SampleTableViewSimpleRegisterPage());
}
protected override void OnStart()

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinStudy.CustomViewCells.CustomViewCell1">
<ViewCell.View>
<StackLayout x:Name="mainStack" Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Label x:Name="titleLabel" FontSize="Large" VerticalTextAlignment="Center" HorizontalOptions="StartAndExpand"/>
<Label x:Name="detailLabel" FontSize="Medium" VerticalTextAlignment="Center"/>
</StackLayout>
</ViewCell.View>
</ViewCell>

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace XamarinStudy.CustomViewCells
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CustomViewCell1 : ViewCell
{
public string Title {
get
{
return titleLabel.Text;
}
set
{
titleLabel.Text = value;
}
}
public string Detail { get => detailLabel.Text; set => detailLabel.Text = value; }
public bool IsVisible { get => mainStack.IsVisible; set => mainStack.IsVisible = value; }
public CustomViewCell1()
{
InitializeComponent();
}
}
}

@ -0,0 +1,17 @@
<?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="XamarinStudy.CustomViewCells.JobSelector">
<ContentPage.Content>
<TableView>
<TableRoot>
<TableSection>
<TextCell Text="Self-employed" Tapped="TextCell_Tapped"/>
<TextCell Text="Employee" Tapped="TextCell_Tapped"/>
<TextCell Text="Student" Tapped="TextCell_Tapped"/>
<TextCell Text="Unemployed" Tapped="TextCell_Tapped"/>
</TableSection>
</TableRoot>
</TableView>
</ContentPage.Content>
</ContentPage>

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XamarinStudy.Views;
namespace XamarinStudy.CustomViewCells
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class JobSelector : ContentPage
{
private SampleTableViewSimpleRegisterPage injectedRP;
public JobSelector(SampleTableViewSimpleRegisterPage sender)
{
InitializeComponent();
injectedRP = sender;
}
private void TextCell_Tapped(object sender, EventArgs e)
{
TextCell result = (TextCell)sender;
injectedRP.SetJob(result.Text);
Navigation.PopToRootAsync();
}
}
}

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:c="clr-namespace:XamarinStudy.CustomViewCells;assembly=XamarinStudy"
x:Class="XamarinStudy.Views.SampleTableViewSimpleRegisterPage">
<ContentPage.Content>
<TableView>
<TableRoot>
<TableSection Title="ID">
<EntryCell Placeholder="Minimum 6 characters"/>
</TableSection>
<TableSection Title="Password">
<ViewCell>
<Entry IsPassword="True" Placeholder="Minimum 8 characters"/>
</ViewCell>
</TableSection>
<TableSection Title="e-Mail">
<EntryCell Placeholder="e-Mail address" Keyboard="Email"/>
</TableSection>
<TableSection>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Label Text="Additional Info"/>
<Switch x:Name="notifySwitch" HorizontalOptions="EndAndExpand" PropertyChanged="notifySwitch_PropertyChanged"/>
</StackLayout>
</ViewCell>
</TableSection>
<TableSection>
<ViewCell>
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" BindingContext="{x:Reference notifySwitch}" IsVisible="{Binding IsToggled}">
<Button x:Name="sexButton" Text="Select" Clicked="sexButton_Clicked"/>
<Label x:Name="sexLabel" Text="Sex" VerticalTextAlignment="Center"/>
</StackLayout>
</ViewCell>
</TableSection>
<TableSection>
<c:CustomViewCell1 x:Name="customCell" Title="Job" Detail="Select after tap" Tapped="customCell_Tapped"/>
</TableSection>
</TableRoot>
</TableView>
</ContentPage.Content>
</ContentPage>

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XamarinStudy.CustomViewCells;
namespace XamarinStudy.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SampleTableViewSimpleRegisterPage : ContentPage
{
public SampleTableViewSimpleRegisterPage()
{
InitializeComponent();
}
private async void sexButton_Clicked(object sender, EventArgs e)
{
string result = await DisplayActionSheet("Sex", "Cancel", null, "Male", "Female");
if (result != "Cancel")
sexLabel.Text = result;
}
private void customCell_Tapped(object sender, EventArgs e)
{
Navigation.PushAsync(new JobSelector(this));
}
public void SetJob(string value)
{
customCell.Title = value;
customCell.Detail = "";
}
private void notifySwitch_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
customCell.IsVisible = notifySwitch.IsToggled;
}
}
}

@ -17,6 +17,12 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="CustomViewCells\CustomViewCell1.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="CustomViewCells\JobSelector.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\SampleAbsoluteLayoutPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
@ -56,6 +62,9 @@
<EmbeddedResource Update="Views\SampleTableViewPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\SampleTableViewSimpleRegisterPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\SampleTabPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>

Loading…
Cancel
Save