From 1c50257f04475923718ef4ddae1345bd29f0f50b Mon Sep 17 00:00:00 2001 From: HARSHITHA S Date: Tue, 23 Apr 2019 15:58:02 +0530 Subject: [PATCH 1/2] Update CollectionViewChallengePage.xaml --- .../Views/CollectionViewChallengePage.xaml | 70 ++++++++++++++----- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml index f2da7f7..f9051e2 100644 --- a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml +++ b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml @@ -1,4 +1,4 @@ - + - - - - - This is a CollectionView! - Your feedback on the experience of converting a ListView to a CollectionView is incredibly appreciated. - Here are three general questions: - 1. How was the experience of converting your existing ListView to a CollectionView? - 2. How is the performance compared to the ListView? - 3. Is there a specific piece of functionality that you'd like to see? - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + From 555faf971531e62264fbc5163bb3777d2c79e827 Mon Sep 17 00:00:00 2001 From: HARSHITHA S Date: Tue, 23 Apr 2019 15:59:14 +0530 Subject: [PATCH 2/2] Update CollectionViewChallengePage.xaml.cs Added layout orientation, scroll to --- .../Views/CollectionViewChallengePage.xaml.cs | 222 +++++++++++++++++- 1 file changed, 218 insertions(+), 4 deletions(-) diff --git a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml.cs b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml.cs index 701124f..ed96ca5 100644 --- a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml.cs +++ b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml.cs @@ -1,6 +1,8 @@ -using System; +using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; @@ -10,11 +12,223 @@ namespace CollectionViewChallenge.Views { [XamlCompilation(XamlCompilationOptions.Compile)] - public partial class CollectionViewChallengePage : ContentPage + public partial class CollectionViewChallengePage : ContentPage, INotifyPropertyChanged { + List oCollectionViewPicker = new List { "Empty List", "Filled List" }; + List oCollectionViewEnabled = new List { "Enable", "Disable" }; + List oCollectionViewLayout = new List { "Horizontal", "Vertical" }; + Dictionary oCollectionViewDic; + private ItemsLayoutOrientation _myProperty; + public CollectionViewChallengePage() { - InitializeComponent(); + try + { + InitializeComponent(); + CVPickerEnabled.ItemsSource = oCollectionViewEnabled; + CVPickerLayout.ItemsSource = oCollectionViewLayout; + CVPicker.ItemsSource = oCollectionViewPicker; + AddItemsToList(); + FillCollectionView(); + AddItemsToScrollToPicker(); + } + catch(Exception oExp) + { + + } + } + + public event PropertyChangedEventHandler PropertyChanged; + public void OnPropertyChanged([CallerMemberName] string name = "") + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + } + + public ItemsLayoutOrientation GILOrientation + { + get + { + return _myProperty; + } + set + { + if (_myProperty != value) + { + _myProperty = value; + OnPropertyChanged(); + } + } + } + + private void AddItemsToScrollToPicker() + { + try + { + List oItems = new List(); + oItems.Add("First Element"); + oItems.Add("Second Element"); + oItems.Add("Third Element"); + oItems.Add("Fourth Element"); + oItems.Add("Fifth Element"); + oItems.Add("Sixth Element"); + oItems.Add("Seventh Element"); + oItems.Add("Eigth Element"); + oItems.Add("Nineth Element"); + oItems.Add("Tenth Element"); + ScrollToPicker.ItemsSource = oItems; + } + catch(Exception oExp) + { + + } + } + private void AddItemsToList() + { + try + { + oCollectionViewDic = new Dictionary(); + oCollectionViewDic.Add("First Element", "tab_about.png"); + oCollectionViewDic.Add("Second Element", "tab_about.png"); + oCollectionViewDic.Add("Third Element", "tab_about.png"); + oCollectionViewDic.Add("Fourth Element", "tab_about.png"); + oCollectionViewDic.Add("Fifth Element", "tab_about.png"); + oCollectionViewDic.Add("Sixth Element", "tab_about.png"); + oCollectionViewDic.Add("Seventh Element", "tab_about.png"); + oCollectionViewDic.Add("Eigth Element", "tab_about.png"); + oCollectionViewDic.Add("Nineth Element", "tab_about.png"); + oCollectionViewDic.Add("Tenth Element", "tab_about.png"); + } + catch(Exception oExp) + { + + } + } + private void FillCollectionView() + { + try + { + List oElements = new List(); + foreach (var items in oCollectionViewDic) + { + ListViewElements NewSectionItem = + new ListViewElements() + { + LVName = items.Key, + LVImage = items.Value + }; + oElements.Add(NewSectionItem); + } + + CollectionListViewH.ItemsSource = oElements; + CollectionListViewV.ItemsSource = oElements; + } + catch(Exception oExp) + { + + } + } + private void CVPicker_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + if (CollectionListViewH.ItemsSource != null && CVPicker.SelectedIndex == 0) + { + CollectionListViewH.ItemsSource = null; + CollectionListViewV.ItemsSource = null; + } + else if (CVPicker.SelectedIndex == 1) + { + AddItemsToList(); + FillCollectionView(); + } + } + catch(Exception oExp) + { + + } } + + private void CVPickerLayout_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + if (CollectionListViewH.ItemsSource != null) + { + if (CVPickerLayout.SelectedIndex == 0) + { + CollectionListViewH.IsVisible = true; + CollectionListViewV.IsVisible = false; + ScrollToPicker.SelectedItem = null; + CVPickerEnabled.SelectedItem = null; + } + else if(CVPickerLayout.SelectedIndex == 1) + { + CollectionListViewH.IsVisible = false; + CollectionListViewV.IsVisible = true; + ScrollToPicker.SelectedItem = null; + CVPickerEnabled.SelectedItem = null; + } + } + } + catch(Exception oExp) + { + + } + } + + private void CVPickedEnabled_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + if (CollectionListViewH.ItemsSource != null) + { + if (CVPickerEnabled.SelectedIndex == 0) + { + CollectionListViewH.IsEnabled = true; + CollectionListViewV.IsEnabled = true; + } + else if (CVPickerEnabled.SelectedIndex == 1) + { + CollectionListViewH.IsEnabled = false; + CollectionListViewV.IsEnabled = false; + } + } + } + catch(Exception oExp) + { + + } + } + + private void CollectionListViewV_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + + } + + private void CollectionListViewH_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + + } + + private void ScrollToPicker_SelectedIndexChanged(object sender, EventArgs e) + { + if (CollectionListViewH.ItemsSource != null && CollectionListViewH.IsVisible) + { + List Items = (List)CollectionListViewH.ItemsSource; + ListViewElements Selecteditem = Items.Select(x => x).Where(y => y.LVName == ScrollToPicker.SelectedItem.ToString()).FirstOrDefault(); + CollectionListViewH.ScrollTo(Selecteditem); + } + else if (CollectionListViewV.ItemsSource != null && CollectionListViewV.IsVisible) + { + List Items = (List)CollectionListViewV.ItemsSource; + ListViewElements Selecteditem = Items.Select(x => x).Where(y => y.LVName == ScrollToPicker.SelectedItem.ToString()).FirstOrDefault(); + CollectionListViewV.ScrollTo(Selecteditem); + } + } + } + public class ListViewElements + { + public string LVName { get; set; } + public string LVImage { get; set; } } -} \ No newline at end of file +}