コード例 #1
0
        private async void OnSuitcaseSorted(object sender, EventArgs e)
        {
            LuggageEventArgs lea = (LuggageEventArgs)e;

            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                                        () =>
            {
                //Inserts the Luggage with its own parameters into the Collection
                if (lea.Luggage.Destination == "Bornholm")
                {
                    SortedSuitcasesBornholm.Insert(0, lea.Luggage);
                }
                else if (lea.Luggage.Destination == "Kairo")
                {
                    SortedSuitcasesKairo.Insert(0, lea.Luggage);
                }
                else if (lea.Luggage.Destination == "Paris")
                {
                    SortedSuitcasesParis.Insert(0, lea.Luggage);
                }
                else if (lea.Luggage.Destination == "Rom")
                {
                    SortedSuitcasesRom.Insert(0, lea.Luggage);
                }
                Suitcases.Remove(lea.Luggage);
            });
        }
コード例 #2
0
        private async void OnLuggageLoaded(object sender, EventArgs e)
        {
            LuggageEventArgs llea = (LuggageEventArgs)e;

            //No idea what this does, but it fixes the crash
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                                        () =>
            {
                //Inserts the Luggage with its own parameters into the Collection
                LoadedSuitcases.Insert(0, llea.Luggage);
                if (llea.Luggage == null)
                {
                    return;
                }

                else
                {
                    if (llea.Luggage.Destination == "Bornholm")
                    {
                        SortedSuitcasesBornholm.Remove(llea.Luggage);
                    }
                    else if (llea.Luggage.Destination == "Kairo")
                    {
                        SortedSuitcasesKairo.Remove(llea.Luggage);
                    }
                    else if (llea.Luggage.Destination == "Paris")
                    {
                        SortedSuitcasesParis.Remove(llea.Luggage);
                    }
                    else if (llea.Luggage.Destination == "Rom")
                    {
                        SortedSuitcasesRom.Remove(llea.Luggage);
                    }
                }
            });
        }