KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Ok, this is kind of odd but this is basically what I need to do. I have a WPF control that is bound to a Document object. The Document object has a Pages property. So in my ViewModel, I have a CurrentDocument property, and a CurrentPage property. Now, I have a combobox that I have bound to the CurrentDocument.Pages property and updates the CurrentPage property. <ComboBox ItemsSource="{Binding CurrentDocument.Pages}" DisplayMemberPath="???" SelectedItem="{Binding CurrentPage, Mode=TwoWay}"> </ComboBox> With me so far? All of this is fine except that I need the DisplayMemberPath to show "Page 1", "Page 2", etc..... I tried creating a converter such as this: public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string pageNumber = "Page {0}"; return string.Format(pageNumber, value); } And tried to bind DisplayMemberPath to it like this: DisplayMemberPath="{Binding RelativeSource={RelativeSource Self}, Path=Index, Converter={StaticResource pgTitleConv}}" But it still wouldn't show up in the combo box text!!! There is no "Index" property but I don't know how to do this...How do I access the index of the item that the combobox is binding to...??????
Tags (comma-separated)
Save Edits
Cancel