private void InitializeCommands() { /// Komeda transferu z prawego listboxa do lewego MoveToLeftCommand = new RelayCommand(button => { if (RightSelectedItem != null) { LeftItemsList.Add(RightSelectedItem); LeftSelectedItem = RightSelectedItem; RightItemsList.Remove(RightSelectedItem); RightSelectedItem = null; } }); /// Komenda transferu z lewego do prawego listboxa MoveToRightCommand = new RelayCommand(button => { if (LeftSelectedItem != null) { RightItemsList.Add(LeftSelectedItem); RightSelectedItem = LeftSelectedItem; LeftItemsList.Remove(LeftSelectedItem); LeftSelectedItem = null; } }); }
// Refresh list - czyści listy a tymczasowa lista temp -> dodaje przedmioty do prawej listy public void RefreshList() { var temporaryList = new List <Item> { new Item { ItemName = "Banan", ItemPrice = 1.25 }, new Item() { ItemName = "Ananas", ItemPrice = 5.88 }, new Item { ItemName = "kokos", ItemPrice = 10 }, new Item { ItemName = "Kawa", ItemPrice = 15.50 }, new Item { ItemName = "Orzechy", ItemPrice = 7.23 }, new Item { ItemName = "Kiełbasa", ItemPrice = 6.50 }, new Item { ItemName = "Ananas", ItemPrice = 6.43 }, new Item { ItemName = "Napój energetyczny", ItemPrice = 4.30 }, }; LeftItemsList.Clear(); RightItemsList.Clear(); temporaryList.ForEach(item => LeftItemsList.Add(item)); }