在WPF的ViewModels创建用户控件 [英] Creating UserControls with ViewModels in WPF

查看:331
本文介绍了在WPF的ViewModels创建用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你认为这是一个很好的做法,已创建一个用户控件与视图模型和部署都在一起吗?通过这种方式,用户控件将从库存中绑定到视图模型。

do you think is a good practise to create a UserControl already with a ViewModel and deploy both together? This way the UserControl will be binded to the ViewModel from stock.

看起来是一个好主意,我,但我从来没有见过这样的事情。

Looks as a good idea to me but I never saw such a thing.

感谢。

推荐答案

有一件事你应该小心的使用这种方法是你想,你正在使用这种控制,让您的DataContext开放,可用于控制结合。

The one thing you should be careful of with this approach is that you want to keep your datacontext open and available for binding to in controls where you are using this control.

如果您阻止数据上下文这将使它所以你的控制的任何绑定以后会有一个源指定。

If you block the data context it'll make it so any bindings you do to the control later will have to have a source specified.

这篇关于在WPF的ViewModels创建用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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