목록 상자 항목에서 구성 요소를 검색해야합니다. 탭 또는 선택 변경 이벤트가 아닙니다. 이것을 달성 할 수있는 간단한 방법이 있습니까? 나는 올바른 기억한다면 , 안드로이드에 그냥 쓸 수 있습니다 : 윈도우 폰에서이 작업을 수행하는 유사한 방법Windows Phone에서 목록 상자 항목의 구성 요소를 찾는 방법은 무엇입니까?
layoutRoot.findViewById(R.id.name);
있습니까?
업데이트 : 여기에 내가 지금까지 뭘하려하지만 작동하지 않습니다 다니엘라 옵션 5 말했다 무엇
내가 ListBoxItem의있을 때 작동하는 것 같다.
private void ListBoxItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
ListBoxItem item = sender as ListBoxItem;
// I can now retrieve a component inside the ListBoxItem
TextBox textBox = item.FindName("myTextBox") as TextBox;
}
하지만이 ListBoxItem의에서 이벤트를 트리거하지 않을 경우이 작업을 수행 할 수 : 나는 예를 들어 ListBoxItem의에 눌러 이벤트가있을 때 그래서 잘 작동합니다. JoonasL은 내가 사용할 수있는 것처럼 보이지만 작동시키지 못합니다.
// will not compile (Cannot implicitly convert type 'object' to...)
ListBoxItem item = x.Items[0];
// if cast the value will be null
ListBoxItem item = x.Items[0] as ListBoxItem;
// will return the object used to populate that ListBoxItem, not the actual ListBoxItem.
// item will have a ItemViewModel object.
List<ItemViewModel> list = ....
this.myListBox.ItemsSource = list;
var item = x.Items[0]
Google에서 검색 할 때 ListBoxItem 내부의 구성 요소를 찾는 데 사용할 수있는 것이 있지만 더 쉬운 방법이라고 생각합니다. 여기서는 VisualTreeHelper을 사용합니다.
당신은 정답을 표시시겠습니까 다른 사람들도 도움을받을 수 있습니까? –
@IrisClasson 내 문제를 해결하지 못했지만 대답을 올바르게 표시 할 수 없습니다. – iixi