Reputation: 681
How do I change the content of the second button, based on the method from the first button with MVVPCross?
Something like this:
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");
}
}
Upvotes: 1
Views: 107
Reputation: 92
Try this:
public void Translate()
{
CallButtonText = "NewText";
RaisePropertyChanged(() => CallButtonText);
}
Upvotes: 1
Reputation: 1595
Please modify your translate method as below:
public void Translate()
{
CallButtonText = "test123";
}
Upvotes: 0