vovgou / loxodon-framework

An MVVM & Databinding framework that can use C# and Lua to develop games
MIT License
1.86k stars 363 forks source link

Databinding Examples #25

Closed holdmycat closed 2 years ago

holdmycat commented 2 years ago

sample scene: loxodon-framework\Loxodon.Framework\Assets\Samples\Loxodon Framework\2.0.0\Tutorials\Databinding Tutorials.unity

DatabindingExamples.cs line 225: bindingSet.Bind(this.usernameEdit).For(v => v.text, v => v.onEndEdit).To(vm => vm.Username).TwoWay();

我认为应该把TwoWay改成OneWayToSource, username inputfield应该是由外部输入决定vm的username,反过来没有意义

vovgou commented 2 years ago

首先TwoWay还是别的,由你自己决定,你根据你自己的需求来定用什么。 其次,InputField的绑定双向的情况很常见,并非只有输入框改变vm的username。比如你的输入界面默认了上次登录的用户名,就是在绑定是将vm.Username 赋值到InputField中。另外如果你的Window界面关闭,但是保留VM,下一次重开时可以通过vm恢复Window界面以前的状态等。

holdmycat commented 2 years ago

明白了,感谢。

1

@. | 签名由网易邮箱大师定制 On 10/27/2021 19:15,Clark @.> wrote:

首先TwoWay还是别的,由你自己决定,你根据你自己的需求来定用什么。 其次,InputField的绑定双向的情况很常见,并非只有输入框改变vm的username。比如你的输入界面默认了上次登录的用户名,就是在绑定是将vm.Username 赋值到InputField中。另外如果你的Window界面关闭,但是保留VM,下一次重开时可以通过vm恢复Window界面以前的状态等。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.