gpt4 book ai didi

mvvm - UWP MVVMCross 将属性绑定(bind)到方法

转载 作者:行者123 更新时间:2023-12-03 10:32:34 24 4
gpt4 key购买 nike

如何根据使用 MVVPCross 的第一个按钮的方法更改第二个按钮的内容?

像这样的东西:

MainPage.xaml:

<Button Content="Translate" Click="{x:Bind PhonewordTranslator.Translate}" />
<Button Content="{x:Bind PhonewordTranslatorViewModel.CallButtonText, Mode=TwoWay}" Click="{x:Bind PhonewordTranslatorViewModel.Call}" />

PhonewordTranslatorViewModel.cs:
public class PhonewordTranslatorViewModel : MvxViewModel
{
...
private string _callButtonText;
public string CallButtonText { get=>_callButtonText; set=>SetProperty(ref _callButtonText, value); }

public void Translate()
{
SetProperty(ref _callButtonText, "test123");
}
}

最佳答案

试试这个:

 public void Translate()
{
CallButtonText = "NewText";
RaisePropertyChanged(() => CallButtonText);
}

关于mvvm - UWP MVVMCross 将属性绑定(bind)到方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52030288/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com