public MainPage() { InitializeComponent(); dragHelper = new DragDropHelper(); State = Persistence.GlobalState.Load(); State.Translations.ChangeLocale(Options.Locale); DataContext = State; SetWindowTitle(); // TODO: move this block to XAML, see http://www.galasoft.ch/mydotnet/articles/article-2007081301.aspx itemCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(LiftItems); itemCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("Category")); itemCollectionView.SortDescriptions.Add(new SortDescription("Category", ListSortDirection.Descending)); itemCollectionView.SortDescriptions.Add(new SortDescription("Title", ListSortDirection.Ascending)); LiftItems.CollectionChanged += (sender, e) => { Console.WriteLine(DateTime.Now + " LiftItems.CollectionChanged/2 triggered"); //UpdateLiftItems(); }; lbLiftItems.SelectedIndex = 0; lbLiftItems.Focus(); // set jumplist items in case they were changed outside of the program Helpers.JumpListHelper.Update(itemCollectionView.Cast <Data.LiftItem>()); //lbLiftItems.DragEnter += new DragEventHandler(lbLiftItems_DragEnter); //lbLiftItems.DragOver += new DragEventHandler(lbLiftItems_DragOver); }
public Options(Persistence.GlobalState state) { InitializeComponent(); internalData = state; System.Windows.Application.Current.MainWindow.Title = state.Translations["Options.Title"]; DataContext = internalData; // TODO set itemsSource from xaml (relative path) cbLanguage.ItemsSource = internalData.Translations.SupportedLanguages; SelectActiveLanguage(); _liftItems = internalData.LiftItems; }