我有一个简单的问题。如何使用 FreshMvvm 框架从页面模型中的 .xaml 文件访问条目值。我希望在 settings.cs 构造函数中设置的默认值是用户在输入字段中输入的值。
谢谢!
测试页.xaml:
<Label Text="Set Server Address (FreshMvvm Binding):" />
<Entry Text="{Binding Settings.SyncServiceAddress}" Placeholder="Server IP Address" />
<Button Text="Sync Web Service - (FreshMvvm Binding)" Command="{Binding SyncButtonFreshMvvmBinding_Clicked}" />
测试页面模型.cs:
public override void Init(object initData)
{
if (initData != null)
{
Settings = (Settings)initData;
}
else
{
Settings = new Settings();
}
}
public Command SyncButtonFreshMvvmBinding_Clicked
{
get
{
return new Command(async () =>
{
string serverAddress = Settings.SyncServiceAddress;
SyncService.PullNewXMLData(serverAddress);
await CoreMethods.PushPageModel<DashboardPageModel>();
});
}
}
设置.cs:
public class Settings : ObservableObject
{
// Constructor
public Settings()
{
// Default value
SyncServiceAddress = "http://localhost/psm/service.aspx";
}
// Properties
public string SyncServiceAddress { get; set; }
public string UserIDSettings { get; set; }
}