Coder Social home page Coder Social logo

Comments (5)

BuzasP avatar BuzasP commented on August 10, 2024

Need to modify the SimpleGalleryPageModel.cs

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Xamvvm;

namespace DLToolkitControlsSamples
{
	public class SimpleGalleryPageModel : BasePageModel
	{
		public void ReloadData()
		{
			var list = new ObservableCollection<ItemModel>();

			string[] images = {
				"https://farm9.staticflickr.com/8625/15806486058_7005d77438.jpg",
				"https://farm5.staticflickr.com/4011/4308181244_5ac3f8239b.jpg",
				"https://farm8.staticflickr.com/7423/8729135907_79599de8d8.jpg",
				"https://farm3.staticflickr.com/2475/4058009019_ecf305f546.jpg",
				"https://farm6.staticflickr.com/5117/14045101350_113edbe20b.jpg",
				"https://farm2.staticflickr.com/1227/1116750115_b66dc3830e.jpg",
				"https://farm8.staticflickr.com/7351/16355627795_204bf423e9.jpg",
				"https://farm1.staticflickr.com/44/117598011_250aa8ffb1.jpg",
				"https://farm8.staticflickr.com/7524/15620725287_3357e9db03.jpg",
				"https://farm9.staticflickr.com/8351/8299022203_de0cb894b0.jpg",
			};

                       int number = 0;
                       string group = "";
                       for (int i = 0; i < images.Length; i++)
                       {
                           number++;
                           if (i < 3) group = "0";
                           else group = "1";
                           var item = new ItemModel()
                           {
                               ImageUrl = images[i],
                               //FileName = string.Format("image_{0}.jpg", number),
                               FileName = group,
                           };

                           list.Add(item);
                       }

                       var sorted = list
                           .OrderBy(item => item.ImageUrl)
                           .GroupBy(item => item.FileName)
                           .Select(itemGroup => new Grouping<string, ItemModel>(itemGroup.Key, itemGroup));

                       Items = new ObservableCollection<object>(sorted);
		}

		public ObservableCollection<object> Items
		{
			get { return GetField<ObservableCollection<object>>(); }
			set { SetField(value); }
		}

		public class ItemModel : BaseModel
		{
			string imageUrl;
			public string ImageUrl
			{
				get { return imageUrl; }
				set { SetField(ref imageUrl, value); }
			}

			string fileName;
			public string FileName
			{
				get { return fileName; }
				set { SetField(ref fileName, value); }
			}
		}

                public class Grouping<K, T> : ObservableCollection<T>
                {
                       public K Key { get; private set; }
           
                       public Grouping(K key, IEnumerable<T> items)
                       {
                           Key = key;
                           foreach (var item in items)
                               this.Items.Add(item);
                       }
                }
        }
}

and the SimpleGalleryPage.xaml

		<flv:FlowListView SeparatorVisibility="None" HasUnevenRows="true"
IsGroupingEnabled="true" FlowGroupDisplayBinding="{Binding Key}" FlowGroupShortNameBinding="{Binding Key}"
			FlowItemTappedCommand="{Binding ItemTappedCommand}" FlowLastTappedItem="{Binding LastTappedItem}"
			FlowColumnMinWidth="110" FlowItemsSource="{Binding Items}">

from dltoolkit.forms.controls.

daniel-luberda avatar daniel-luberda commented on August 10, 2024

Thanks @BuzasP :)

from dltoolkit.forms.controls.

onszaidi1 avatar onszaidi1 commented on August 10, 2024

Please why SetField and GetField don't work for me ?

from dltoolkit.forms.controls.

kormemis avatar kormemis commented on August 10, 2024

@BuzasP code is not working , sorted cannot convert to items , does anyone has idea ?

from dltoolkit.forms.controls.

Sonic3R avatar Sonic3R commented on August 10, 2024

Where is BasePageModel ? Why not full sample there ?

from dltoolkit.forms.controls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.