Accessing the selected element inside a templated textblock bound to a wpf listbox
Posted
by black sensei
on Stack Overflow
See other posts from Stack Overflow
or by black sensei
Published on 2010-05-12T13:39:43Z
Indexed on
2010/05/12
15:24 UTC
Read the original article
Hit count: 431
Hello good people , i'm trying to achieve a functionality but i'm don't know how to start it. I'm using vs 2008 sp1 and i'm consuming a webservice which returns a collection (is contactInfo[]) that i bind to a ListBox with little datatemplate on it.
<ListBox Margin="-146,-124,-143,-118.808" Name="contactListBox" MaxHeight="240" MaxWidth="300" MinHeight="240" MinWidth="300">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<CheckBox Name="contactsCheck" Uid="{Binding fullName}" Checked="contacts_Checked" /><Label Content="{Binding fullName}" FontSize="15" FontWeight="Bold"/> <LineBreak/>
<Label Content="{Binding mobile}" FontSize="10" FontStyle="Italic" Foreground="DimGray" /> <Label Content="{Binding email}" FontStyle="Italic" FontSize="10" Foreground="DimGray"/>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Every works fine so far. so When a checkbox is checked i'll like to access the information of the labels (either the) belonging to the same row or attached to it and append the information to a global variable for example (for each checkbox checked).
My problem right now is that i don't know how to do that.
Can any one shed some light on how to do that?
if you notice Checked="contacts_Checked"
that's where i planned to perform the operations. thanks for reading and helping out
© Stack Overflow or respective owner