获取"Itemdata"从WPF ComboBox-ItemTemplate [英] Getting "Itemdata" from WPF ComboBox - ItemTemplate
问题描述
我在下面的XML中留下了小于号而不是第一个字符,因为它不想正确粘贴.
我是WPF的新手,但仍在尝试弄清楚基础知识.我终于获得了填充组合框的数据(请参见下面的XAML),但是现在我需要知道当用户单击一个选择时如何在VB.NET中从其中获取数据.
以前就像combobox.itemdata(1)
您到底如何使用WPF和ItemTemplate做到这一点
感谢您的帮助!
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>
谢谢!
ItemTemplate
DataTemplate
StackPanel
文字块
Thank you!
ItemTemplate
DataTemplate
StackPanel
TEXTBLOCK
How do I get the data in TEXTBLOCK?
推荐答案
This link should most certainly give an idea on how we can do this using SelectedItem
in a combobox in WPF
这篇关于获取"Itemdata"从WPF ComboBox-ItemTemplate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!