如何在C#WPF中使用分页创建列表框 [英] How to create listbox with paging in C# WPF

查看:648
本文介绍了如何在C#WPF中使用分页创建列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是WPF的新手.我正在尝试在WPF中实现一个弹出窗口,该窗口将在运行时显示,其中包含CountryList的动态绑定.用户可以从列表中选择一个国家,此窗口应作为对话框结果返回选定的国家.

我想知道如何创建带有分页的ListBox?

如果有人可以帮助我,使用Code或任何有用的链接将非常有用.

我尝试过的事情:

我尝试过使用滚动条渲染ListBox,但无法将其用作分页.

I am new to WPF. I am trying to implement a Popup window in WPF which will be shown at runtime, with dynamic binding of CountryList in it. User can select one country from the list and this Window should return as selected Country as Dialog Result.

I want to know, how can i create a ListBox with paging?

If anyone can help me with this would be great with Code or any useful link.

What I have tried:

I have tried rendering ListBox with scrollbars, but not able to make it as paging.

推荐答案

0)您不必返回任何内容.在列表项类中只有一个名为IsSelected的属性,然后在绑定的列表框中进行选择时将其设置为true.

1)ListBox控件允许您通过单击滚动条箭头来翻页.我不明白为什么您会觉得需要自定义控件.

2)世界上少于200个国家.您为什么要关心只有这么几个条目的分页.您应该拥有一个搜索文本框,该文本框执行自定义处理,以选择以用户在文本框中输入的字符开头的国家/地区.
0) You don''t have to return anything. Just have a property in your list item class called IsSelected, and set it to true when a selection is made in the bound listbox.

1) The ListBox control allows you to page by clicking the scrollbar arrows. I don''t understand why you feel that you need a custom control for this.

2) There are fewer than 200 countries in the world. Why are you concerned with paging with that few entries. What you SHOULD have is a search textbox that performs custom processing to select the country that starts with characters as they are entered by the user in the textbox.


这篇关于如何在C#WPF中使用分页创建列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆