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# 创建Windows Service
当我们需要一个程序长期运行,但是不需要界面显示时可以考虑使用Windows Service来实现.这篇博客将简单介绍一下如何创建一个Windows Service,安装/卸载Windows Servi ...
- Java Server returned HTTP response code: 401
今天写一个小功能需要通过http请求获取一些返回数据,但是在登陆时是需要进行用户名和密码的校验的.写好之后请求,返回异常Java Server returned HTTP response code: ...
- C#写Windows Service(windows服务程序)
背景: 要学习使用一个新东西,我们必须知道他是个什么东西.对于我们此次研究的windows服务来说,他又是个什么东西,其实也没有什么高深的了. windows service概述: 一个 ...
- 消息提示插件toastr.js与Messenger组件
Toastr是一款基于jQuery的通知插件,可以灵活的自定义样式和拓展其功能! toastr是一个基于Jquery简单.漂亮的消息提示插件,使用简单.方便,可以根据设置的超时时间自动消失. cdn最 ...
- Jmeter 分布式性能测试
作为一个纯 JAVA 的GUI应用,JMeter 对于CPU和内存的消耗还是很惊人的,所以当需要模拟数以千计的并发用户时,使用单台机器模拟所有的并发用户就有些力不从心,甚至还会引起JAVA内存溢出的错 ...
- this和super
1.this * 每个类的每个非静态方法(没有被static修饰)都会隐含一个this引用名称,它指向调用这个方法的对象. * 当在方法中使用本类的属性时,都会隐含地使用this名称,当然也可以明确指 ...
- LR检查点的if (status == LR_FAIL)写法
C语言例子:登录失败返回一个信息 int status = web_url("Login", "URL=https://secure.computing.com//log ...
- 时间和地域三级联动选择器(Android-PickerView-master)
先附上下载和效果展示地址 https://github.com/saiwu-bigkoo/Android-PickerView 之后说一下程序依赖后会遇到的问题Error:(2, 0) Plugin ...
- hdu 1029 Ignatius ans the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- SpringRMI解析4-客户端实现
根据客户端配置文件,锁定入口类为RMIProxyFactoryBean,同样根据类的层次结构查找入口函数. <bean id="rmiServiceProxy" class= ...