Tag:ar for on Code amp as res window app
private void Stackpanel_tap (object sender, Tappedroutedeventargs e) {//Gets the object is ListBoxItem Listboxi Tem mylistboxitem = (listboxitem) (ListBox. Itemcontainergenerator.containerfromitem (sender as Panel). DataContext)); Find ContentPresenter ContentPresenter mycontentpresenter = findvisualchild<contentpresenter> in ListBoxItem (m Ylistboxitem); ...//omit several codes}//Find the element of a type of visual tree private ChildItem findvisualchild<childitem> (DependencyObject obj) where child Item:dependencyobject {for (int i = 0; i < visualtreehelper.getchildrencount (obj); i++) { DependencyObject child = Visualtreehelper.getchild (obj, i); if (child! = NULL && child was ChildItem) return (ChildItem) child; else {ChildItem Childofchild = findvisualchild<childitem> (child); if (childofchild! = null) return childofchild; } } return null; }
Find an element of a type in the visual tree in Windows Phone