Why WPF ?

Here is a simple shopping cart application implemented in both Windows Forms and / windows Presentation Framework.

 

There are some minor differences in both apps. Although the List of controls in WPF application usually have same names, their behaviour or capabilities vary. In Short, WPF controls are richer in functionality than Windows Form Controls.


Check this.

 

One could simply set the ItemSorce Property of the ListBox to a Collection in WPF, work on collection and just call refresh method for ListBox Control to load the items.

 

Will have to  use Add Range() method in Windows Form App as ListBox Control in Windows Forms lacks this capability to refresh its contents from any assigned data source.

 

WPF App


shoppingCartList.ItemsSource = shoppingCart; // List<>

 

// Do Somethig with List such as

 

shopingCartList.Refresh();

 

 

 

Win Forms App


// Clear the Items List for ListBox

shopingCartList.Items.Clear();

 

// Add the items from List<> to ListBox using AddRange() Method

ShopingCartList.Items.AddRange(shoppinCart.ToArray());