I have a UserControl with a ListView inside the ItemTemplate property has a ComboBox i need use two datacontext for this ComboBox
- ItemsSource DataContext from UserControl
- SelectedItem DataContext from ListViewItem
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.
You can use
RelativeSourcein your binding to traverse the Visual Tree to find theDataContext for UserControl.Whereas for
ListViewItem, you don’t need RelativeSource sinceCombobox will inherit the DataContext of its parent which is ListViewItemitself. Your structure would look somewhat like this –