如何使用Xamarin.forms MVVM中的挑选器中的选择器绑定属性模型中的属性
首先,如果我的英语不好,我很抱歉。 我想制作一个翻译应用程序,这个应用程序与谷歌翻译相同,有两个不同的选择器可以用来更改语言(源语言和目标语言),就像这张图片一样 [AppsImages][1]
[选择器 1,用于更改语言源/来自][2]
[选择器 2,用于更改语言目标/到][3]
要进行翻译,前端必须发送您想要的文本翻译是用户输入,有关源(语言源/来自)和目标(语言目标/目标)的信息。 我设法让这个应用程序通过用户输入进行翻译,但我对有关源(语言源/来自)和目标(语言目标/目标)的信息进行了编码{还不是选择器的结果}
我想要什么时候单击 picker1(语言来源/来源选择器),它将更改视图模型中的属性 source 将设置为字符串(“en”表示英语,“kr”表示韩语,“id” “ 为了印度尼西亚语),picker2 也一样。
[xaml代码][4] [查看模型][5]
我该怎么做? 谢谢.. [1]: https://i.sstatic.net/tiyd7.png [2]: https://i.sstatic.net/Pa7yd.png [3]: https://i.sstatic.net/Ou5qs.png [4]: https://i.sstatic.net/GInIn.png [5]: https://i.sstatic.net/ZzSIy.png
First of all, i am sorry if my english is bad.
I want to make a translator apps, this apps are the same like google translate, there is two different picker that can be use to change the language (source language and language target ) just like this picture
[AppsImages][1]
[picker 1, for change the language source/from ][2]
[picker 2, for change the language target/to][3]
To do the translation, the frontend must send the text you want to translate which is user input, information about source (language source/from), and target (language target/to).
I managed to make this application do the translation via user input, but I did harcode for information about source (language source/from) , and target (language target/to) {not yet the result of the picker}
I want to make when picker1 (picker for language source/from) is clicked, it will change the property source in the view model will be set to a string ("en" for english, "kr" for korean and "id" for indonesian), same too for picker2.
[xaml code][4]
[view model][5]
How do I do that?
Thank you..
[1]: https://i.sstatic.net/tiyd7.png
[2]: https://i.sstatic.net/Pa7yd.png
[3]: https://i.sstatic.net/Ou5qs.png
[4]: https://i.sstatic.net/GInIn.png
[5]: https://i.sstatic.net/ZzSIy.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们只需要在
SelectedItem
属性上创建绑定,当项目更改时,viewmodel 中的属性也会更改。Xaml
ViewModel
请参阅 响应项目选择。
We just need to create binding on
SelectedItem
property , when the item changes ,the property in viewmodel will get changed as well .Xaml
ViewModel
Refer to Responding to item selection.