Binding MvvmCross Android对话框以编程方式绑定
我想在我的MvvmCross项目中使用Android.Dialog(Binding MvvmCross Android对话框以编程方式绑定,binding,android-dialog,mvvmcross,Binding,Android Dialog,Mvvmcross,我想在我的MvvmCross项目中使用Android.Dialog(Cross.UI)。我的第一个方法是使用自动视图。由于该功能还相当年轻,替代方案是在touch和Droid平台上实现对话 现在我只是为Droid做这个,我需要通过编程将ViewModel的属性绑定到对话框的元素 我的视图和视图模型代码如下所示: 看法 我的目标是用属性ViewModel.Configuration.Name双向绑定EntryElement(“Name:”) 有人能帮我吗?可以这样做吗?我不知道是否有任何monod
Cross.UI
)。我的第一个方法是使用自动视图。由于该功能还相当年轻,替代方案是在touch和Droid平台上实现对话
现在我只是为Droid做这个,我需要通过编程将ViewModel的属性绑定到对话框的元素
我的视图和视图模型代码如下所示:
看法
我的目标是用属性ViewModel.Configuration.Name
双向绑定EntryElement(“Name:”)
有人能帮我吗?可以这样做吗?我不知道是否有任何monodroid.dialog mvvmcross示例在不使用AutoView的情况下浮动 然而。。。。绑定的基本syntac应与MonoTouch.Dialog相同,例如:
new Section("Contact Info")
{
new StringElement("ID", ViewModel.Customer.ID ?? string.Empty),
new EntryElement("Name", "Name").Bind(this, "{'Value':{'Path':'Customer.Name'}}"),
new EntryElement("Website", "Website").Bind(this, "{'Value':{'Path':'Customer.Website'}}"),
new EntryElement("Primary Phone", "Phone").Bind(this, "{'Value':{'Path':'Customer.PrimaryPhone'}}"),
},
new Section("Primary Address")
{
new EntryElement("Address").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.Street1'}}"),
new EntryElement("Address2").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.Street2'}}"),
new EntryElement("City").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.City'}}"),
new EntryElement("State").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.State'}}"),
new EntryElement("Zip").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.Zip'}}"),
},
从
请注意,在MonoTouch和MonoDroid的MvvmCross绑定中,文本编辑框之类的默认绑定通常默认为双向
如果你确实得到了一个运行的示例,那么请随意将其发布到一个要点或一个回购协议,或者发布到关于它的博客,看起来我们可以使用一些示例来工作 我一定会调查的。我会尽快发布我的结果,一旦我得到这个例子的工作。谢谢好像少了一些东西。。。但现在我已经添加了它们:)请参阅提交,非常感谢您找到这个缺失的缺口!我才是该说谢谢的人!我还没开始看他,问题就解决了…:)明天早上我会更新我的叉子,之后我可以发布一个工作样本
public class DialogConfigurationViewModel : MvxViewModel
{
public ConfigurationSet Configuration
{
get { return _configuration; }
set
{
if (_configuration != value)
{
_configuration = value;
RaisePropertyChanged(() => Configuration);
}
}
}
private ConfigurationSet _configuration;
}
new Section("Contact Info")
{
new StringElement("ID", ViewModel.Customer.ID ?? string.Empty),
new EntryElement("Name", "Name").Bind(this, "{'Value':{'Path':'Customer.Name'}}"),
new EntryElement("Website", "Website").Bind(this, "{'Value':{'Path':'Customer.Website'}}"),
new EntryElement("Primary Phone", "Phone").Bind(this, "{'Value':{'Path':'Customer.PrimaryPhone'}}"),
},
new Section("Primary Address")
{
new EntryElement("Address").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.Street1'}}"),
new EntryElement("Address2").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.Street2'}}"),
new EntryElement("City").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.City'}}"),
new EntryElement("State").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.State'}}"),
new EntryElement("Zip").Bind(this, "{'Value':{'Path':'Customer.PrimaryAddress.Zip'}}"),
},