-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from muak/PickerCellSurvey
fix PickerCell #16
- Loading branch information
Showing
8 changed files
with
242 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using System.Collections.ObjectModel; | ||
using System.Threading.Tasks; | ||
using System.Windows.Input; | ||
using Xamarin.Forms; | ||
using System; | ||
|
||
namespace Sample.ViewModels | ||
{ | ||
class PickerSurveyViewModel | ||
{ | ||
public ObservableCollection<Person> MasterItemsSource { get; } = new ObservableCollection<Person>(); | ||
public ObservableCollection<Person> MasterItemsSourceSelectedItems { get; } = new ObservableCollection<Person>(); | ||
|
||
public ObservableCollection<Person> SlaveItemsSource { get; } = new ObservableCollection<Person>(); | ||
public ObservableCollection<Person> SlaveItemsSourceSelectedItems { get; } = new ObservableCollection<Person>(); | ||
|
||
string[] type = { "letters", "number" }; | ||
|
||
string[] listLetters = { "a", "b", "c", "d", "e" }; | ||
string[] listNumbers = { "1", "2", "3", "4", "5" }; | ||
|
||
public PickerSurveyViewModel() | ||
{ | ||
foreach (var item in type) | ||
{ | ||
MasterItemsSource.Add(new Person() | ||
{ | ||
Name = item, | ||
Age = 1 | ||
}); | ||
} | ||
|
||
} | ||
|
||
ICommand selectMasterCommand; | ||
public ICommand SelectMasterCommand => | ||
selectMasterCommand ?? (selectMasterCommand = new Command(async () => await ExecuteSelectMasterCommand())); | ||
|
||
async Task ExecuteSelectMasterCommand() | ||
{ | ||
try | ||
{ | ||
|
||
if (MasterItemsSourceSelectedItems.Count == 0) | ||
return; | ||
|
||
SlaveItemsSource.Clear(); | ||
SlaveItemsSourceSelectedItems.Clear(); | ||
|
||
|
||
await Task.Delay(100); | ||
|
||
switch (MasterItemsSourceSelectedItems[0].Name) | ||
{ | ||
case "letters": | ||
|
||
foreach (var item in listLetters) | ||
{ | ||
SlaveItemsSource.Add(new Person() | ||
{ | ||
Name = item, | ||
Age = 1 | ||
}); | ||
} | ||
|
||
|
||
break; | ||
case "number": | ||
foreach (var item in listNumbers) | ||
{ | ||
SlaveItemsSource.Add(new Person() | ||
{ | ||
Name = item, | ||
Age = 1 | ||
}); | ||
} | ||
|
||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
|
||
|
||
SlaveItemsSourceSelectedItems.Add(SlaveItemsSource[0]); | ||
|
||
} | ||
catch (Exception ex) | ||
{ | ||
|
||
} | ||
finally | ||
{ | ||
|
||
} | ||
} | ||
} | ||
|
||
//public class Person | ||
//{ | ||
// public string Name { get; set; } | ||
// public int Age { get; set; } | ||
//} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?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:local="clr-namespace:TestAiForms" | ||
xmlns:sv="clr-namespace:AiForms.Renderers;assembly=SettingsView" | ||
x:Class="Sample.Views.PickerSurvey"> | ||
|
||
<ContentPage.Resources> | ||
<ResourceDictionary> | ||
<!-- アプリ全体の背景色 --> | ||
<Color x:Key="AppBackground">#ffffff</Color> | ||
<!-- アクセントカラー --> | ||
<Color x:Key="AccentColor">#FFBF00</Color> | ||
<!-- 非アクティブカラー --> | ||
<Color x:Key="DisabledColor">#E6DAB9</Color> | ||
<!-- タイトルテキストカラー --> | ||
<Color x:Key="TitleTextColor">#CC9900</Color> | ||
<!-- 薄い背景色1 --> | ||
<Color x:Key="PaleBackColorPrimary">#F2EFE6</Color> | ||
<!-- 薄い背景色2 --> | ||
<Color x:Key="PaleBackColorSecondary">#F2EDDA</Color> | ||
<!-- 濃いめの文字色 --> | ||
<Color x:Key="DeepTextColor">#555555</Color> | ||
<!-- 通常文字色 --> | ||
<Color x:Key="NormalTextColor">#666666</Color> | ||
<!-- 薄い文字色 --> | ||
<Color x:Key="PaleTextColor">#999999</Color> | ||
<!-- 強調文字色 --> | ||
<Color x:Key="EmphasisTextColor">#FF0000</Color> | ||
<!-- 通常フォントサイズ --> | ||
<x:Double x:Key="BaseFontSize">12</x:Double> | ||
<!-- ちょい大きいフォントサイズ --> | ||
<x:Double x:Key="BaseFontSize+">14</x:Double> | ||
<!-- 大きいフォントサイズ --> | ||
<x:Double x:Key="BaseFontSize++">17</x:Double> | ||
<!-- ちょい小さいフォントサイズ --> | ||
<x:Double x:Key="BaseFontSize-">11</x:Double> | ||
|
||
<Style TargetType="sv:SettingsView"> | ||
<Setter Property="SeparatorColor" Value="{StaticResource DisabledColor}" /> | ||
<Setter Property="BackgroundColor" Value="{StaticResource PaleBackColorPrimary}" /> | ||
<Setter Property="HeaderBackgroundColor" Value="{StaticResource PaleBackColorPrimary}" /> | ||
<Setter Property="CellBackgroundColor" Value="{StaticResource AppBackground}" /> | ||
<Setter Property="CellTitleColor" Value="{StaticResource DeepTextColor}" /> | ||
<Setter Property="CellValueTextColor" Value="{StaticResource NormalTextColor}" /> | ||
<Setter Property="CellTitleFontSize" Value="{StaticResource BaseFontSize++}" /> | ||
<Setter Property="CellValueTextFontSize" Value="{StaticResource BaseFontSize}" /> | ||
<Setter Property="CellDescriptionColor" Value="{StaticResource NormalTextColor}" /> | ||
<Setter Property="CellDescriptionFontSize" Value="{StaticResource BaseFontSize-}" /> | ||
<Setter Property="CellAccentColor" Value="{StaticResource AccentColor}" /> | ||
<Setter Property="SelectedColor" Value="#50FFBF00" /> | ||
<Setter Property="HeaderTextColor" Value="{StaticResource TitleTextColor}" /> | ||
<Setter Property="FooterFontSize" Value="{StaticResource BaseFontSize-}" /> | ||
<Setter Property="FooterTextColor" Value="{StaticResource PaleTextColor}" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</ContentPage.Resources> | ||
|
||
<sv:SettingsView HasUnevenRows="true" HeaderHeight="36" HeaderPadding="14,0,0,6" HeaderTextVerticalAlign="End" FooterPadding="14,4,4,6"> | ||
|
||
<sv:Section x:Name="svv" Title="Select a letter and then select a number..." FooterText="...the old letter value is still visible, even if you clear the selecteditems in viewmode"> | ||
|
||
<sv:PickerCell Title="number o letter?" ItemsSource="{Binding MasterItemsSource}" DisplayMember="Name" MaxSelectedNumber="1" | ||
SelectedItems="{Binding MasterItemsSourceSelectedItems}" SelectedCommand="{Binding SelectMasterCommand}" ValueText="" | ||
KeepSelectedUntilBack="true" PageTitle="Select" /> | ||
</sv:Section> | ||
|
||
<sv:Section Title="Select detail"> | ||
<sv:PickerCell Title="Detail" ItemsSource="{Binding SlaveItemsSource}" DisplayMember="Name" MaxSelectedNumber="1" | ||
SelectedItems="{Binding SlaveItemsSourceSelectedItems}" KeepSelectedUntilBack="true" PageTitle="Select" ValueText="" /> | ||
</sv:Section> | ||
|
||
</sv:SettingsView> | ||
|
||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Xamarin.Forms; | ||
|
||
namespace Sample.Views | ||
{ | ||
public partial class PickerSurvey : ContentPage | ||
{ | ||
public PickerSurvey() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters