Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ComboBox, ItemTemplate and DisplayMemberPath

$
0
0
Hi,
 
Please can someone help?

I have a combobox bound to a collection using the ItemsSource property. The ComboBox has an ItemTemplate defined as I want to display something like Name and Description from the ItemsSource for each item. However, once the item has been selected I only want the Name to be displayed in the ComboBox selection area (i.e. not the drop down list part). The ComboBox is not Editable.

This is what I have so far:

        <ComboBox Margin="10,0,10,10" ItemsSource="{Binding Path=Profiles}"   
                  SelectedValue="{Binding ProfileName}"   
                  SelectedValuePath="Name">  
            <ComboBox.ItemTemplate> 
                <DataTemplate> 
                    <StackPanel> 
                        <TextBlock Text="{Binding Path=Name}"></TextBlock> 
                        <TextBlock Margin="10" FontSize="8" Text="{Binding Description}"></TextBlock> 
                    </StackPanel> 
                </DataTemplate> 
            </ComboBox.ItemTemplate> 
        </ComboBox> 
 

I just don't know how to change the format of the selected item away from the format defined by the ItemTemplate.

Any help would be great.

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>