限制项目控件中显示的行数 [英] Limit the number of rows displayed in Items control
本文介绍了限制项目控件中显示的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种方法来限制在项目控件中显示的行数. ?
Is there a way to limit the number of rows that get displayed in items control. ?
我有一个绑定到Items控件的可观察字符串集合.我想将要显示的行数限制为仅一.该集合可以有多个.
I have a observable collection of strings which are bound to Items control. I want to limit the number of rows to display to only one. The collection can have more than one.
谢谢
推荐答案
假设您的ItemsSource
设置为MyObservableCollection
.
好吧,如果更改ItemsSource
以使其指向MyOneItemCollection
怎么办?
Well, what if you change your ItemsSource
so that it is pointing a MyOneItemCollection
instead?
然后,只需使用LINQ来执行以下操作:
Then, just use LINQ to do something like this:
using System.Linq;
MyOneItemCollection = MyObservableCollection.First();
或
using System.Linq;
MyOneItemCollection = MyObservableCollection.Single(item => item.Id = MyId);
这篇关于限制项目控件中显示的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文