[英]MVVM Binding with exposed property
I have a View that is hooked to a ViewModel. 我有一个连接到ViewModel的View。 I have a singleton class that's exposed by foo.Current.
我有一个由foo.Current公开的单例类。 I have a property on that class that will be changing as the result of a button click command calling a foo.Current function.
我在该类上有一个属性,它将通过调用foo.Current函数的按钮单击命令进行更改。 I want to be able to bind a textbox's text to that value and when that value updates the textbox will update.
我希望能够将文本框的文本绑定到该值,当该值更新时,文本框将更新。 My ViewModel does implement INotifyPropertyChanged and I have other properties on the view model that update controls fine.
我的ViewModel确实实现了INotifyPropertyChanged,我在视图模型上有其他属性可以更新控件。 What is the best way I can make that singleton class update my ViewModel with the new value?
我可以使用单值类用新值更新ViewModel的最佳方法是什么? I'm thinking I need to figure out a way to make the Singleton class update the ViewModel.
我想我需要想办法让Singleton类更新ViewModel。
There's no "best" way in current situation, options are as follows: 目前的情况没有“最佳”方式,选项如下:
Easiest one would be the first option though there might be some architectural inconsistencies in your app that should be treated. 尽管您的应用中可能存在一些应该被处理的架构不一致,但最简单的方法是第一个选项。
如果我理解你,我会使用Observer模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.