wpf进度条数据绑定到命令
我想以简单的方式使用进度条。我有一个查询,当用户单击按钮时,该查询将运行以将数据返回到网格。我想在单击按钮时启动进度条,并在数据返回到网格时停止进度条。
我只是希望进度条继续(IsInminateate =“True”)以表明确实发生了一些事情。
有没有办法将进度条的开始和停止绑定到我的视图模型中的属性或命令?
感谢您的任何想法。
I would like to use a progressbar in a simple way. I have a query that is run to return data to a grid when a user clicks a button. I would like to start the progressbar when the button is clicked and stop the progressbar when the data is returned to the grid.
I just want the progressbar to continue on (IsIndeterminate="True") to show that there is actually something happening.
Is there any way to bind the start and stop of the progressbar to properties or commands in my view model?
Thanks for any thoughts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
IsInminateate
属性作为您的属性来绑定 ViewModel 上的属性;在此示例中,我的标题为IsBusy
。在此实例中,XAML 使用
Button
的单击事件处理程序;然而,在您的实例中,您只需绑定您的操作,这将开始对 ViewModel 上的命令进行处理。当您开始工作和结束工作时,修改 ViewModel 上的
IsBusy
属性将开始和停止不确定行为,提供活动/非-您所追求的活跃视觉外观。Use the
IsIndeterminate
property as your property to bind against a property on your ViewModel; mine is titledIsBusy
in this example.The XAML is in this instance uses a click event handler for the
Button
; however in your instance you would simply bind your action which will start your processing to the command on your ViewModel.As you begin work and end work modifying the
IsBusy
property on your ViewModel will then start and stop the indeterminate behavior, providing the active/not-active visual appearance you are after.您可以公开一个属性,然后使用该属性来触发
ProgressBar
的可见性,但最好使用包含进度条的控件并公开用于打开/关闭进度条的属性。例如,BusyIndicator
中扩展的 WPF 工具包。You could expose a property that you then use to trigger the visibility of the
ProgressBar
, but you're better off using a control that encompasses a progress bar and exposes a property that turns it on/off. For example, theBusyIndicator
in the Extended WPF Toolkit.