LongListSelector with bindable SelectedItem
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Phone.Controls; namespace ExtendedControls
{
public class ExtendedSelector : LongListSelector
{
public static readonly DependencyProperty SelectedItemProperty =
DependencyProperty.Register("SelectedItem", typeof (object), typeof (ExtendedSelector), new PropertyMetadata(default(object))); public static readonly DependencyProperty SelectionModeProperty =
DependencyProperty.Register("SelectionMode", typeof (SelectionMode), typeof (ExtendedSelector), new PropertyMetadata(default(SelectionMode))); public SelectionMode SelectionMode
{
get { return (SelectionMode) GetValue(SelectionModeProperty); }
set { SetValue(SelectionModeProperty, value); }
} public new object SelectedItem
{
get { return GetValue(SelectedItemProperty); }
set { SetValue(SelectedItemProperty, value); }
} public ExtendedSelector()
{
SelectionMode = SelectionMode.Single; SelectionChanged += (sender, args) =>
{
if(SelectionMode == SelectionMode.Single)
SelectedItem = args.AddedItems[0];
else if (SelectionMode == SelectionMode.Multiple)
{
if (SelectedItem == null)
{
SelectedItem = new List<object>();
} foreach (var item in args.AddedItems)
{
((List<object>)SelectedItem).Add(item);
} foreach (var removedItem in args.RemovedItems)
{
if (((List<object>) SelectedItem).Contains(removedItem))
{
((List<object>) SelectedItem).Remove(removedItem);
}
}
}
};
}
}
}
LongListSelector with bindable SelectedItem的更多相关文章
- Windows Phone中的几种集合控件
前言 Windows Phone开发过程中不可避免的就是和集合数据打交道,如果之前做过WP App的开发的话,相信你已经看过了各种集合控件的使用.扩展和自定义.这些个内容在这篇博客里都没有,那么我们今 ...
- Windows Phone 8初学者开发—第15部分:在选中ListItem时播放声音
原文 Windows Phone 8初学者开发—第15部分:在选中ListItem时播放声音 第15部分:在选中ListItem时播放声音 原文地址: http://channel9.msdn.co ...
- 与众不同 windows phone (34) - 8.0 新的控件: LongListSelector
[源码下载] 与众不同 windows phone (34) - 8.0 新的控件: LongListSelector 作者:webabcd 介绍与众不同 windows phone 8.0 之 新的 ...
- WindowsPhone8中LongListSelector的扩展解决其不能绑定SelectdeItem的问题
微软在Wp8中集成了LongListSelector, 但是该控件在ViewModel中不能实现的SelectdeItem双向绑定,因为其不是DependencyProperty没办法只能实现扩展! ...
- 设置 LongListSelector 只有在项多的时候才分组
Windows Phone 中的控件LongListSelector是一个很好的分组聚类控件,当列表中数据特别多的时候,LongListSelector就像字典中的目录,让我们很快定位到要找的数据. ...
- WPF中,Combox的SelectedItem属性绑定成功后,未能默认显示上一次选择的结果。
问题描述: Combox中,设定了绑定对象,但是在第一次进入时却没有显示上次选中的项. 1)查看SelectedItem对应绑定的值,也是有的(启动时,读取上次设置的结果,来初始化界面). ...
- WinPhone学习笔记(五)——LongListSelector
LongListSelector也是WinPhone的特色控件之一,最初不了解这个控件叫啥名,知道它会在"人脉"里面出现,在应用程序列表也是这个LongListSelector(如 ...
- Windows Phone 8 LongListSelector实现下拉自动刷新列表
LongListSelector是一个加强版的列表控件,它可以实现分组的列表,如系统人脉列表的交互效果就可以利用LongListSelector控件去实现,同时LongListSelector也一样可 ...
- 解答WPF中ComboBox SelectedItem Binding不上的Bug
正在做一个打印机列表,从中选择一个打印机(System.Printing) <ComboBox Width="150" ItemsSource="{Binding ...
随机推荐
- C#从Image上读取文本
今天通过C#来实现一个读取Image上文本的功能. 1. 环境准备: 1). 下载 Microsoft Office SharePoint Designer 2007. 2). 安装请参考KB:htt ...
- Ubuntu下快速安装php环境
今天蛋疼了一下,在Ubuntu下装了一下php的环境,也就是装了一下MySQL.PHP.Apache.话说还真是简单...不禁让我想起原来在windows下开发的时候撑死就是装不上,而且一个就是几个G ...
- JSP/Servlet的编码原理
转自:http://janwer.iteye.com/blog/150226 首先,说说 JSP/Servlet 中的几个编码的作用 在 JSP/Servlet 中主要有以下几种设置编码的方式: pa ...
- JVM字节码之整型入栈指令(iconst、bipush、sipush、ldc)
官网:http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html 原文地址:http://www.linmuxi.com/2016/02 ...
- linux中预留的$变量
$0表示bash脚本的文件名 $1表示第一个参数 $*表示参数列表$0, $1, $2… $@表示"$1"/"$2"...每个变量都是独立的,用双引号括起来 $ ...
- Android ViewPager使用详解(转)
这是谷歌官方给我们提供的一个兼容低版本安卓设备的软件包,里面包囊了只有在安卓3.0以上可以使用的api.而viewpager就是其中之一利用它,我们可以做很多事情,从最简单的导航,到页面菜单等等.那如 ...
- 长按事件jquery mobile
chat_enlarge.addEventListener('touchend', function(event) { if(fingers == 1){ event.preventDefault() ...
- 关于解决haswell赛扬和奔腾 不能安装的问题
打开EFI\CLOVER\config.plist,并找到KernelAndKextPatches字段,在子集内插入下面代码. <key>FakeCPUID</key> < ...
- Intel CPU MMX SSE SSE2/3/4指令集手册下载URL
在线查看的网址: https://software.intel.com/sites/landingpage/IntrinsicsGuide/ Intel® 64 and IA-32 Architect ...
- 多个$(document).ready()函数的执行顺序问题,(未解决)
今天遇到了一个问题: jQuery获取不了动态添加的元素,我使用的是append添加的.寻求了帮助,得到解决方案: 在文件开头写上这样一段代码来获取,写在$(document).ready()里面. ...