Xaml - 将现有控件添加到网格
尝试使用 MVVM 进行开发:
我有在我的 ViewModel 中创建的 Csla.PropertyStatus 控件。 我想将它添加到 xaml 中(我认为是通过绑定)并在那里设置一些附加属性(例如目标)。
我不知道我怎么能做到这一点,即使这是可能的。
我一直在寻找类似的东西,
<csla:PropertyStatus Instance="{Binding Path=MyStatus}"
Target="{Binding ElementName=txtTextBox}"
Grid.Column="2" Grid.Row="0"/>
这可能以某种方式吗?...我需要在 ViewModel 中创建它,因为我需要设置一些不允许视图(XAML)知道的属性。
编辑: 我所说的属性是模型。 PropertyStatus 需要对业务对象的引用才能执行验证。 但考虑到 MVVM 的范式(或者按照我的理解),视图应该与模型解耦,并且应该只知道 ViewModel。不过,我可能会改变这种方法......
Trying to develop using MVVM:
I have this Csla.PropertyStatus control that is created in my ViewModel.
I want to add it in the xaml (via binding, i think) and set some additional properties there (such as the target).
I don't know how i could do that, not even if that is possible.
I was looking for something like
<csla:PropertyStatus Instance="{Binding Path=MyStatus}"
Target="{Binding ElementName=txtTextBox}"
Grid.Column="2" Grid.Row="0"/>
Is that possible somehow?... i NEED to create it in the ViewModel because i need to set some property that the view (XAML) is not allowed to know about.
Edit:
The property i'm talking about is the model. The PropertyStatus needs a reference to the business object to perform the validation.
But considering the paradigm of MVVM (or as i understand it), the view should be decoupled from the model, and should only know about the ViewModel. I might change that approach, though...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能这样做。顺便说一句,视图都是关于 UI 控件及其属性的,因此说视图不允许“了解”其元素之一的属性有点……极端。在这里描述您想要完成的任务可能有助于为您提供一个不错的答案。
You CAN'T do this. BTW, the view is all about UI controls and their properties, so saying the view is not allowed to "know about" a property on one of its elements is a bit... extreme. A description of what you are trying to accomplish here might help in providing you with a decent answer.