using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using PhoxKitV2_Lib.Entities.Photo;
using PhoxKitV2_Lib.Helpers;
using System.ComponentModel;
using System.Globalization;
namespace Sorting_Collections
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : System.Windows.Window
{
private ObservableCollection<PhoxKitV2_Lib.Entities.Photo.Lecteur> collec_Lecteurs = new ObservableCollection<PhoxKitV2_Lib.Entities.Photo.Lecteur>();
public Window1()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(Window1_Loaded);
}
void Window1_Loaded(object sender, RoutedEventArgs e)
{
Lecteur lec = new Lecteur();
lec.Lecteur_Collec_Dossiers = new ObservableCollection<Dossier>();
//lec.Lecteur_Collec_Dossiers_Dispatch = new DispatchingCollection<ObservableCollection<Dossier>, Dossier>(lec.Lecteur_Collec_Dossiers, this.Dispatcher);
lec.Lecteur_Lettre = 1.ToString().ToCharArray()[0];
for (int i = 1; i < 10; i++)
{
Dossier doss = new Dossier();
doss.Dossier_DateCreation = new DateTime(2006, i, 25);
doss.Dossier_Path = "path_" + i.ToString();
doss.Dossier_Nom = "Dossier " + i.ToString();
lec.Lecteur_Collec_Dossiers.Add(doss);
}
for (int i = 1; i < 10; i++)
{
Dossier doss = new Dossier();
doss.Dossier_DateCreation = new DateTime(2006, 2, 25);
doss.Dossier_Path = "path_" + (i+1).ToString();
doss.Dossier_Nom = "Dossier " + i.ToString();
lec.Lecteur_Collec_Dossiers.Add(doss);
}
for (int i = 1; i < 10; i++)
{
Dossier doss = new Dossier();
doss.Dossier_DateCreation = new DateTime(2006, 4, 25);
doss.Dossier_Path = "path_5";
doss.Dossier_Nom = "Dossier " + i.ToString();
lec.Lecteur_Collec_Dossiers.Add(doss);
}
ICollectionView view = CollectionViewSource.GetDefaultView(lec.Lecteur_Collec_Dossiers);
view.GroupDescriptions.Clear();
view.GroupDescriptions.Add(new PropertyGroupDescription("Dossier_DateCreation", new DateTimeToDateConverter()));
this.lst_Lecteurs.ItemsSource = lec.Lecteur_Collec_Dossiers;
}
}
public class DateTimeToDateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((DateTime)value).ToString("MM/dd/yyyy");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
Partager