最新评论
sinodragon21 2012-05-16 11:29
最近在Windows Phone 8上做动画animation/transition,学习了,谢谢。
dino623 2012-01-27 14:34
[quote]羽之:
@dino623
他让你测试一下你这个DEMO的性能如何?[/quote]
上班后再搞吧 = =
其实我想他直接告诉我结果会如何。
dino623 2012-01-24 14:10
[quote]傻瓜力量大:建议博主你试试在datagrid 中 放入大量的列 40个左右并且 在datagrid中你放入 templatecolumn 在templatecolumn中在放入datagrid 你试试 看看性能如何[/quote]
有什么意义?
傻瓜力量大 2012-01-24 10:44
建议博主你试试在datagrid 中 放入大量的列 40个左右并且 在datagrid中你放入 templatecolumn 在templatecolumn中在放入datagrid 你试试 看看性能如何
游路 2011-12-01 17:14
上面的问题解决了。
使用分页之后,this.DataContext 只保存分页之后的数据集合。
使用PagedCollectionView 的SourceCollection属性可以获得基础的 IEnumerable 集合。
我用这个集合可以得到所有选中的项。
感谢楼主提供的代码!
下面是符合我要求的代码
[code=csharp]
public List<object> GetSelectedItems()
{
List<object> result = new List<object>();
IEnumerable ienum = (OwnerDataGrid.ItemsSource as PagedCollectionView).SourceCollection;
if (ienum != null)
{
foreach (object obj in ienum)
{
if (GetMarkObject(obj).Selected)
result.Add(obj);
}
}
return result;
}
[/code]
游路 2011-12-01 15:48
我按照楼主的这个方法建了一个TestDataGrid3。
对这个TestDataGrid3进行分页之后好像不好用了。只能得到当前页的选择项,其它页中选择的项获得不了。
[code=csharp]
//this.DataContext = list; //将这行改为下面的三行
PagedCollectionView pcv = new PagedCollectionView(list);
pcv.PageSize = 5;
this.DataContext = pcv;
[/code]
XAML中加了一个DataPager 。
[code=html]
<!--LayoutRoot中加了第三行-->
<sdk:DataPager x:Name="DpaBar" Grid.Row="2" Grid.ColumnSpan="4" Source="{Binding}" Language="zh-CN" IsTotalItemCountFixed="False" />
[/code]
遇到这样的问题怎么解决呢?
dino623 2011-11-25 19:58
@浅蓝色
public class MarkObject : INotifyPropertyChanged
{
bool _selected;
public bool Selected
{
get { return _selected; }
set
{
if (_selected == value)
return;
_selected = value;
NotifyPropertyChanged("Selected");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
浅蓝色 2011-11-25 18:26
非常感谢,很有用。
能不能把MarkObject的代码也发一下呢?在全选的时候,我没法通过ItemSource找到全部的CheckBox
点滴心语 2011-11-02 11:45
多谢博主。今天我试着给MyGrid加上一个控制属性(IsShowCheckBox),让用户选择是否要显示checkbox列。
结果发现不管用,然后 OnLoadingRow 方法报错了,不知能否帮忙看看?QQ:519174300
dino623 2011-10-31 19:50
@点滴心语
[quote]点滴心语:
报错,扩展方法必须在非泛型静态类中定义
楼主的 public static T GetChild<T>(this DependencyObject obj, string name = null) where T : FrameworkElement
这段代码是加载什么地方?[/quote]
我有这么一个类,类似这样的类很普遍的,因为这几个方法在SL中很常用。
[code=csharp]
public static class VisualTreeExtensions
{
public static T GetParent<T>(this DependencyObject obj, string name = null) where T : FrameworkElement
{
DependencyObject parent = VisualTreeHelper.GetParent(obj);
while (parent != null)
{
if (parent is T && (((T)parent).Name == name || string.IsNullOrEmpty(name)))
{
return (T)parent;
}
parent = VisualTreeHelper.GetParent(parent);
}
return null;
}
public static T GetChild<T>(this DependencyObject obj, string name = null) where T : FrameworkElement
{
DependencyObject child = null;
T grandChild = null;
for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
{
child = VisualTreeHelper.GetChild(obj, i);
if (child is T && (((T)child).Name == name | string.IsNullOrEmpty(name)))
{
return (T)child;
}
else
{
grandChild = GetChild<T>(child, name);
if (grandChild != null)
return grandChild;
}
}
return null;
}
public static List<T> GetChildren<T>(this DependencyObject obj, string name = null) where T : FrameworkElement
{
DependencyObject child = null;
List<T> childList = new List<T>();
for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
{
child = VisualTreeHelper.GetChild(obj, i);
if (child is T && (((T)child).Name == name || string.IsNullOrEmpty(name)))
{
childList.Add((T)child);
}
childList.AddRange(GetChildren<T>(child, ""));
}
return childList;
}
}
[/code]
点滴心语 2011-10-31 14:15
报错,扩展方法必须在非泛型静态类中定义
楼主的 public static T GetChild<T>(this DependencyObject obj, string name = null) where T : FrameworkElement
这段代码是加载什么地方?