WPF:ListView中的进度条
我正在尝试在 ListView
中显示来自 ObservableCollection
的信息。 MyData
具有:
string Name
string Location
int Progress
使用 DataBinding
,我能够显示我的所有项目的 Name
和 Location
ObservableCollection
在他们自己的列中。但是如何添加一个带有 ProgressBar
的 Progress
列呢? 进度
是一个百分比。
I'm trying to display information from my ObservableCollection<MyData>
in a ListView
. MyData
has:
string Name
string Location
int Progress
Using DataBinding
, I'm able to display the Name
and Location
for all the items in my ObservableCollection<MyData>
in their own column. But how can I add a Progress
column with a ProgressBar
inside? Progress
is a percentage.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
XAML 中的 ListView:
代码隐藏:
Your ListView in XAML:
Code-behind:
只需将 MyData 中的 Progress 属性绑定到 ProgressBar.Value 并将预期的 MAX 值设置为 ProgressBar.Maximum,例如下面的 50
Just bind Progress property in MyData to the ProgressBar.Value and set the expected MAX value as the ProgressBar.Maximum for example 50 below