我仍在学习使用 MVVM 和 Prism,并有一些一般性问题:
-
我的视图中有一个网格。可以说我
有一个按钮,当我点击时我
希望它自动调整网格大小
列。该代码会去哪里?
调整网格列的大小是一个视图问题
并且视图模型不应该知道
关于它。所以在这种情况下我会
添加按钮点击处理程序
视图的代码在后面吗?我有
与网格编辑相同的问题和
验证。视图模型可以看到
当使用双向编辑值时
具有约束力,但如果它决定
值无效,如何通知
取消编辑的网格?
-
假设我的视图有许多用户
控件和每个用户的控件需求
绑定到来自不同对象的数据。该视图的视图模型是否只是一个巨大的类,其中包含视图的所有不同组件所需的所有数据?
-
关于Prism和模块化设计,我
我想弄清楚什么是
“模块”是。我的理解是
模块是独立的,
意思是如果我拿起我的模块并且
将其放入另一个应用程序中,它应该
工作。所以如果我有课
进行一些服务调用(让
说对服务器的 SOAP 调用得到一些
信息)并填充网格,我的模块
需要包括 MVVM
组件和我的服务层,
正确的?如果我有多个模块
使用相同的服务层,确实
每个都需要包含服务层类的副本
为了被认为是一个完整的
模块?
感谢您的任何建议/信息。
I am still learning to use MVVM and Prism and have some general questions:
-
I have a grid in my view. Lets say I
have a button that when I click I
want it to auto size the grid
columns. Where would that code go?
Resizing grid columns is a view thing
and the view model shouldn't know
about it. So in this case would I be
adding the button click handler in
the view's code behind? I have the
same question with grid editing and
validation. The view model can see
when a value is edited with two-way
binding but if it decides that the
value is invalid, how can it notify
the grid to cancel the edit?
-
Lets say my view has a number of user
controls and each user control needs
to bind to data from a different object. Would my view model for this view just be a huge class with all of the data I would need for all of the different components of the view?
-
Regarding Prism and modular design, I
am trying to figure out what a
"module" is. My understanding is
that a module is self contained,
meaning if I pick up my module and
drop it in another app, it should
work. So if I have a class
that makes some service calls (lets
say SOAP calls to a server get some
info) and populates a grid, my module
would need to include both the MVVM
components and my service layer,
right? If I have multiple modules
that use the same service layer, does
each one need to include a copy of the service layer classes
in order to be considered a complete
module?
Thanks for any advice/info.
发布评论
评论(1)
我将尝试分别讨论这些项目。
如果您刚开始使用 Prism 并有任何其他问题,您可能会发现 codeplex 论坛很有用,例如也许 Prism SE 团队已经回答了您的问题。
我希望这个答案有帮助。
谢谢,
达米安
I'll try to go over these items separately.
If you are getting started with Prism and have any other questions, you might find the codeplex forum useful, as perhaps your question has been answered there by the Prism SE team.
I hope this answer helps.
Thanks,
Damian