I am binding a Xaml Combobox. Can i use Stackpanel or List? Can u explain how to bind data in such a way?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To start you’ll need some data with public properties for the URI of the image and text you want to display with it. Here’s a simple example to use below:
You’ll then need another public property to hold some collection of that data item. This property needs to be on an object that can be set as a DataContext somewhere in your view or can be assigned directly to your ComboBox in code-behind:
Assuming that the DataContext of some parent element of the ComboBox has been assigned to the object containing the ImageList property you can then use this to bind the collection and display a simple image and text for each item:
You will probably also want some size constraints on your Image by setting MaxWidth and/or MaxHeight.