windows phone listbox的点击事件
来源:互联网 发布:android 数据库路径 编辑:程序博客网 时间:2024/06/06 18:11
前台
<ListBox x:Name="listbox1" Margin="6"><ListBox.ItemTemplate><DataTemplate><Grid Margin="15" Tag="{Binding ImageID}" Tap="Post_Click"><StackPanel Orientation="Horizontal"><Image Source="{Binding Image}" Width="150" Height="120" Stretch="Fill"/><TextBlock Text="{Binding ImageName}" FontSize="30" TextWrapping="Wrap" Width="300"/></StackPanel></Grid></DataTemplate></ListBox.ItemTemplate></ListBox>
后台
private T FindFirstElementInVisualTree<T>(DependencyObject parentElement) where T : DependencyObject{var count = VisualTreeHelper.GetChildrenCount(parentElement);if (count == 0)return null;for (int i = 0; i < count; i++){var child = VisualTreeHelper.GetChild(parentElement, i);if (child != null && child is T){return (T)child;}else{var result = FindFirstElementInVisualTree<T>(child);if (result != null)return result;}}return null;}
需要绑定
private void Post_Click(object sender, System.Windows.Input.GestureEventArgs e){var selectedIndex = listbox1.SelectedIndex;ListBoxItem item = listbox1.ItemContainerGenerator.ContainerFromIndex(selectedIndex) as ListBoxItem;StackPanel border = FindFirstElementInVisualTree<StackPanel>(item);Image img = FindFirstElementInVisualTree<Image>(item);TextBlock txtBlock = FindFirstElementInVisualTree<TextBlock>(item);MessageBox.Show(txtBlock.Text.ToString());}
阅读全文
0 0
- windows phone listbox的点击事件
- Windows Phone 多次点击事件
- Windows Phone 7下ListBox的使用
- Windows Phone ListBox的分页加载
- Windows Phone listBox
- Windows Phone中的路由事件-以ListBox控件为例
- Windows Phone开发使用横向滑动的ListBox
- windows phone:【listBox】WP7 中最好的ListBox 滚动后分批加载的方法
- Listbox 重复点击事件不能响应的解决方法
- Windows Phone开发之 ListBox控件
- windows phone 中ListBox采用多模板
- Windows Phone ListBox无法滚动到底部
- Windows Phone 事件处理
- listbox的事件
- ListBox控件模拟鼠标点击事件
- windows phone 7 长按listbox的item,并弹出菜单操作
- Windows Phone开发之独立存储、文件的读写、ListBox绑定数据、NavigationService实现XAML跳转
- windows phone 7 ListBox使用图片触摸时放大实现
- Python爬虫之实习僧招聘信息及数据分析
- windows phone 存储图片 数据库写法
- LeetCode 131. Palindrome Partitioning 树形问题,状态回溯
- 华为实习day1
- 嵌入式笔试题(3)
- windows phone listbox的点击事件
- [bzoj1293][SCOI2009]生日礼物 单调队列优化dp
- 选择排序
- ZOJ--1003:Crashing_Balloon(因子分解)
- linux下的父子进程的验证代码
- 训练赛---咏叹
- Maven快速入门
- 旧版漏洞 Bug 被发现可致 Win7/8.1 “崩溃”
- MySQL入门--删除数据库、修改数据库编码集、显示数据库创建信息