0
votes

Im cleaning up this question and going to put in an example that makes sense to me..hopefully for you too...

so lets say i have an Items control. This control is bound to an observable collection of NBA Basketball teams (Lakers, Heat, Knicks...ect). In this observable collection of NBATeams I have a property of FavoritePlayer. I have a datatemplate that lays out how this is going to look inside the Items Control. I have a textbox which displays the team name. (this could be/should be read only..its not now) but it displays the team name.. LA Lakers. the second item in my items control is a combobox. this combo box will ultimately display my favorite player on each team.

The itemssource on the combobox is from a lookup value i have. It displays all the people on the team and the displaymemberpath on this combobox is "DisplayText"...I need my selected item on this combobox to be shown. so if my favorite player is Kobe Bryant the combo box should display this.

<telerik:RadComboBox Grid.Row="0" Grid.Column="9" Width="150" EmptyText="--Select Player--"
 ItemsSource="{Binding PlayerList}" 
 SelectedItem="{Binding FavoritePlayer, Mode=TwoWay}" 
 DisplayMemberPath="DisplayText" HorizontalAlignment="Left"></telerik:RadComboBox>

I am used to just having textblocks in a listbox and then when an item is selected from within that listbox i use that selected item to bind my comboboxes that live outside of my listbox. Now i actually have the combobox in the listbox(ItemsControl now). So Im wondering the best way to bind the combobox from within an ItemsControl

I initially was just having issues getting the players to show up in the combobox..but I solved that by doing the code below.

I found my first issue of just binding the items source to the combo box from within an items control.

I had to set the bindings to look like this.

ItemsSource="{Binding DataContext.PlayerList, ElementName=ItemsControlNBATeams}"

so i had to set the name of the items control and use that in the element name and set the path = to DataContext.PlayerList. this now brings up the items in my combo box..what it doesnt do is set the selecteditem of my combo box.

1
Could you phrase the question a little more clearly?foson
Cleaned up the question a bit..thanks fosongevjen

1 Answers

0
votes

Not very clear about your you are asking but does this answer your question

    <ListBox ItemsSource="{Binding}" x:Name="ListBox1"></ListBox>
    <TextBox Text="{Binding SelectedItem, ElementName=ListBox1}">  </TextBox>