我有一个应用程序,其中大多数控件是在代码中创建的,然后使用AddView方法添加到布局中.框架是否允许使用代码将ViewModel属性绑定到控件,或者只能在axml文件中完成?
我有一个看起来像这样的对象结构。
public class Model : MvxViewModel
{
private IDictionary<string, string> _properties;
public IDictionary<string, string> Properties
{
get { return _properties; }
}
public string this[string key]
{
get { return Get(key); }
set { Set(key, value); ;}
}
public Model()
{
this._properties = new Dictionary<string, string>();
}
public void Set(string propertyName, string value)
{
if (!_properties.ContainsKey(propertyName))
{
_properties[propertyName].Value = value;
}
}
public string Get(string propertyName)
{
return _properties[propertyName];
}
}
Run Code Online (Sandbox Code Playgroud)
我需要使用 Fluent API 将此对象的信息绑定到控件。我的控件是在代码中创建的。
代码如下所示:
protected override void OnCreate(Bundle …Run Code Online (Sandbox Code Playgroud)