views:

142

answers:

1

I'm having trouble with a combox databinding, this is what I'm trying to have it setup like:

1) Combo box is an item inside of a ListBox control [working]

2) Combo box's "Text" should be bound to a value from the ListBox ItemsSouce [not working]

3) The combo box will have an itemssource bound to a list that is retreived from a database [working]

Other items in this ListBox databind correctly, it is only the Combo Box I'm struggling with.

This is my xaml, any help is greatly appreciated.

<ComboBox 
    ItemsSource="{Binding Source={StaticResource ODPTaskCategories}}"
    Text="{Binding Path=Category}"
    FontFamily="Tahoma" 
    FontSize="14" 
    Height="24.91" 
    Margin="278,66.96,8,0" 
    Name="ddlCategory" 
    VerticalAlignment="Top" 
    VerticalContentAlignment="Center" 
    HorizontalAlignment="Stretch" 
    Width="Auto" 
    SelectionChanged="ddlCategory_SelectionChanged"  />

The objective is to allow the user to choose an item from the Combo Box from a pre-defined list and have that databound to the ListBox's databound item.

+2  A: 

Check out the SelectedItem property. Also the order seems to matter.

<ComboBox 
    SelectedItem="{Binding Path=Category}"
    ItemsSource="{Binding Source={StaticResource ODPTaskCategories}}"
    FontFamily="Tahoma" 
    FontSize="14" 
    Height="24.91" 
    Margin="278,66.96,8,0" 
    Name="ddlCategory" 
    VerticalAlignment="Top" 
    VerticalContentAlignment="Center" 
    HorizontalAlignment="Stretch" 
    Width="Auto" 
    SelectionChanged="ddlCategory_SelectionChanged"  />
Lars Truijens
Excellent, thanks! I'd been using Text property before and not had any issues, SelectedItem is great!
Nate Bross