As a question:, look directly at the code:
/// <summary> ///finds and returns the first child element of the same name/// </summary> /// <typeparam name= "T" >the type of child control you want to find</typeparam> /// <param name= "obj" >The type of control that needs to find the next face control</param> /// <param name= "ChildName" >the name of the child control</param> /// <returns></returns> Public StaticT findfirstvisualchild<t> (DependencyObject obj,stringChildName)whereT:dependencyobject { for(inti =0; I < Visualtreehelper.getchildrencount (obj); i++) {DependencyObject child=visualtreehelper.getchild (obj, i); if(Child! =NULL&& Child isT && Child. GetValue (System.Windows.FrameworkElement.NameProperty). ToString () = =childname) { return(T) child; } Else{T Childofchild= findfirstvisualchild<t>(Child, ChildName); if(Childofchild! =NULL) { returnChildofchild; } } } return NULL; }
This is probably the case, the parameters of the above method and so on things are very clear. This time the demand is to click in the ListBox, you need to determine which one to click, you need to pass the ID to the second page to determine what the second page shows. And my listbox is all tile (Windows Phone), so I'm going to get the ID I need by clicking on the event below.
Private voidButton_click_1 (Objectsender, RoutedEventArgs e) {Tile B= (Sender) asTile; //finds the value in TextBlock that is hidden under control c4f, which is the value of the IDTextBlock C = iscau.tools.domehandle.findfirstvisualchild<textblock> (b,"Mark"); Navigationservice.navigate (NewUri ("/syncfood/foodmenu.xaml?id="+C.text, urikind.relative)); }
Get control child control in Silverlight