Advance controls are the controls that are used to create more complex and interactive user interfaces.
This are more interactive controls than the basic controls and use to display large amount of data in a structured way. These controls are used to create more complex and interactive user interfaces.
ListBox
Simple list of items that can be selected by the user.
You can use it to display a list of items and allow the user to select one or more items from the list.
You can use ItemsSource property to bind the list of items to the ListBox. You can also use SelectedItem property to get the selected item from the ListBox.
Code behind is similar to windows forms ListBox control
ListView is similar to ListBox but it provides more functionality and flexibility. It can be used to display a list of items in a tabular format with multiple columns.
ListView inherits from ListBox, so you can use all the properties and methods of ListBox in ListView.
You can also completely customize the layout of ListView items using DataTemplate. like using Borders, Images, Buttons in listview items.
publicclassFriend{publicstringName{get;set;}=string.Empty;publicintAge{get;set;}publicoverridestringToString(){return$"{Name} ({Age})";}}```````csharp//code to populate ListView Item with multiple columnsFriendsListView.Items.Add(newFriend{Name="Deven",Age=25});FriendsListView.Items.Add(newFriend{Name="Dhruv",Age=28});FriendsListView.Items.Add(newFriend{Name="Yogesh",Age=30});
publicclassClient{publicstringName{get;set;}publicdoubleRate{get;set;}}publicpartialclassMainWindow:Window{publicMainWindow(){InitializeComponent();Clients=[ new Client { Name = "Client 1", Rate = 100, }, new Client { Name = "Client 2", Rate = 200, }, ];DataContext=this;}publicList<Client>Clients{get;set;}}
Listview Data Template
DataTemplate allow us to specify how the data should be displayed in the ListView.
This is different from style which mostly deals with visual aspects of the control. DataTemplate is used to define the visual representation of the data in the ListView.