WPF依赖项属性MVVM [英] WPF dependency property MVVM

查看:118
本文介绍了WPF依赖项属性MVVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建用户控件,该控件将做一些工作,然后填充三个依赖项属性,然后将这些属性通过绑定由控件的父元素使用.

I am in the process of creating a user control, this control will do some work and then populate three dependency properties, which will then used by parent elements of the control through binding.

我的问题是使用MVVM在哪里保留依赖项属性的最佳实践是什么? 我应该为MVVM使用框架吗?

My question is what are the best practices on where to keep the dependency properties using MVVM? Should I use a framework for MVVM?

谢谢

推荐答案

惯用的依赖项属性与ViewModel表示的视图状态"无关,也没有理由将它们添加到ViewModel中.我会将它们放在一个文件中,该文件包含您正在实现的控件的行为.

Idiomatic dependency properties have nothing to do with 'view state' as represented by the ViewModel and there is no reason to add them to the ViewModel. I would place them in a file that contains the behavior for the control that you are implementing.

这篇关于WPF依赖项属性MVVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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