Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I left the less than sign off the first character in the XML below as it didnt want to paste in properly.

I am new to WPF and still trying to get the basics figured out. I finally got data to populate the combobox (see XAML below) but now I need to know how to get the data out of it in VB.NET when the user clicks on a selection.

The old days it was like combobox.itemdata(1)

How on earth do you do this with the WPF and ItemTemplate

Thanks for any help!

combobox margin="248,72,15,0" name="comboBox2" datacontext="{StaticResource AccountsViewSource}" itemssource="{Binding}" verticalalignment="Top" height="20" background="Plum">

combobox.itemtemplate>
 <datatemplate>

 stackpanel orientation="Horizontal">
 textblock text="{Binding Accountnum}" width="100" />
 textblock text="{Binding Description}" width="200" />
 /stackpanel>

/datatemplate>

/combobox.itemtemplate>
 /combobox>

</datatemplate>



Thank you!


ItemTemplate
DataTemplate
StackPanel
TEXTBLOCK

How do I get the data in TEXTBLOCK?
Posted
Updated 12-May-10 6:54am
v3

1 solution

This link should most certainly give an idea on how we can do this using SelectedItem in a combobox in WPF
 
Share this answer
 
Comments
mworsnop 12-May-10 12:53pm    
That doesnt do what I need. I need to be able to get the TEXTBLOCK section data

ItemTemplate
DataTemplate
StackPanel
TEXTBLOCK

How do I get the data in TEXTBLOCK?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900