windows phone 7 - Gettting the values of TextBox from a data bound ListBox -


Hello, I need to get the value of the selected item Suchiboksejh I note, data template data are bound here xaml :

  & lt; List Box Name = "appointment Rijhltdeta" Aitmssors = "{Binding}" height = "650" width = "480" Margin = "24,0,0,0" foreground = "# Sibif 7 FA" Select Chenjd = "appointment Rijhltdetasncln Changed "& gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Grid & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; ColumnDefinition / & gt; & Lt; /Grid.ColumnDefinitions> & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; /Grid.RowDefinitions> & Lt; TextBlock Text = "{Binding Path = Subject, Mode = Dove}" TextWoping = "Wrap" fontSysize = "30" Grid. Column = "0" grid. Line = "1" /> & Lt; Grid grid. Column = "0" grid. Line = "2" & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; ColumnDefinition / & gt; & Lt; ColumnDefinition / & gt; & Lt; /Grid.ColumnDefinitions> & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; RowDefinition / & gt; & Lt; /Grid.RowDefinitions> & Lt; TextBlock Text = "{Binding Path = Account.}" Grid. Column = "0" grid. Line = "1" fontism = "28" /> & Lt; TextBlock Text = "Start:" Grid. Column = "0" font seices = "22" grid. Rows = "2" /> & Lt; Textbox text = "{binding path = start time}" fonticij = "22" grid. Column = "1" grid. Line = "2" /> & Lt; Text Block Text = "End:" Grid Column = "0" grid. Line = "3" fontism = "22" /> & Lt; TextBlock Text = "{Binding Path = End Time}" Grid. Column = "1" fontSize = "22" grid. Rau = "3" /> & Lt; TextBlock Text = "Location:" Grid. Column = "0" grid. Line = "4" fontism = "22" /> & Lt; Text block text = "{binding path = location}" grid. Column = "1" font system = "22" grid. Line = "4" /> & Lt; Text block text = "status:" grid. Column = "0" font seices = "22" grid. Raw = "5" /> & Lt; TextBlock Text = "{Binding Path = Status}" Grid. Column = "1" font seices = "22" grid. Raw = "5" /> & Lt; / Grid & gt; & Lt; Text block text = "" /> & Lt; / Grid & gt; & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt;   

I need the values ​​of the text box in the selection box. I like to try ...

  private void appointment Rijhltsdetasncln Chenjed (object sender, select Chenjedaventargs e) {// Cynitivent Sileted = appointment selected as Rijltdetakcynitivent; If (Appointment Results) Selected Index == -1 returns; ListBoxItem currentSelectedListBoxItem = this. AppointmentResultsData.ItemContainerGenerator.ContainerFromIndex (AppointmentResultsData.SelectedIndex) as ListBoxItem; If return (currently selected LIBBOX == empty) return; // Replace the entire list tree again and search for this item. Text box namebox = helper class.andandsendant & lt; Text box & gt; (Currently selected listbox items); Text Block Name Block = Assistant Class. Find & lt; TextBlock & gt; (Currently selected listbox items); MessageBox.Show (nameBlock.Text + "" + nameBox.Text); }   

But it does not work!

Resolve it!

  private void AppointmentResultsData_SelectionChanged (object sender, SelectionChangedEventArgs e) {var listBoxItem = AppointmentResultsData.ItemContainerGenerator.ContainerFromIndex (AppointmentResultsData.SelectedIndex) as listBoxItem; Var txtBlk = DiscoveryVisual Childbipes & lt; TextBlock & gt; (Listbox, "txtLocation"); MessageBox.Show (txtBlk.Text); } FindVisualChildByType & lt; T & gt; (Dependency object element, String name) where T: class {if (element & amp; amp; amp; amp; amp; amp; amp; & amp; element; FrameworkElement) Knam == name) as t Return element; Int childcount = VisualTreeHelper.GetChildrenCount (element); For (; I & lt; i = 0 int childcount; i ++) {t childElement = FindVisualChildByType & lt; T & gt; (VisualTreeHelper.GetChild (element, i) name); If (child Element! = Null) returns child's education; } Return tap; }    

Comments