本文整理汇总了C#中Android.Views.View.GetBindingTag方法的典型用法代码示例。如果您正苦于以下问题:C# View.GetBindingTag方法的具体用法?C# View.GetBindingTag怎么用?C# View.GetBindingTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Views.View
的用法示例。
在下文中一共展示了View.GetBindingTag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnbindView
public void UnbindView (View view)
{
if (view == null)
return;
var tag = view.GetBindingTag ();
if (tag != null) {
if (tag.Bindings != null) {
foreach (var binding in tag.Bindings) {
binding.Dispose();
}
tag.Bindings.Clear();
}
_viewTags.RemoveAll(weak => weak.Target == tag || weak.Target == null);
}
var viewGroup = view as ViewGroup;
if (viewGroup != null) {
var count = viewGroup.ChildCount;
for (var i = 0; i < count; i++) {
UnbindView(viewGroup.GetChildAt(i));
}
}
}
示例2: BindViewTree
/// <summary>
/// Traverses the view hierarchy and updates the bindings.
/// </summary>
protected void BindViewTree(object dataSource, View view, IList<WeakReference> reusableBindings = null) {
var tag = view.GetBindingTag ();
if (tag != null) {
if (!tag.BindingEnabled)
return;
if (tag.OverrideDataSource)
dataSource = tag.DataSource;
if (tag.BindingDescriptions != null) {
if (dataSource == null) {
MvxBindingTrace.Trace(
MvxTraceLevel.Warning,
"Binding view {0} with an empty data source.",
view.GetType().Name);
}
if (tag.Bindings.Count > 0 || dataSource != null) {
// Try to reuse weak reference for the tag:
WeakReference weakTag = null;
if (reusableBindings != null) {
for (var i = 0; i < reusableBindings.Count; i++) {
if (reusableBindings[i] == null)
continue;
if (reusableBindings[i].Target == tag) {
weakTag = reusableBindings[i];
reusableBindings[i] = null;
}
}
}
if (weakTag == null)
weakTag = new WeakReference(tag);
_viewTags.Add(weakTag);
if (tag.Bindings.Count > 0) {
// Update old bindings only:
foreach (var binding in tag.Bindings) {
binding.DataContext = dataSource;
}
} else {
// Create bindings:
var bindings = this.GetService<IMvxBinder>()
.Bind(dataSource, view, tag.BindingDescriptions);
if (bindings != null) {
foreach (var binding in bindings) {
tag.Bindings.Add(binding);
}
}
}
}
}
}
var viewGroup = view as ViewGroup;
if (viewGroup != null) {
var count = viewGroup.ChildCount;
for (var i = 0; i < count; i++) {
BindViewTree(dataSource, viewGroup.GetChildAt(i), reusableBindings);
}
}
}
示例3: Attach
public void Attach (View view, IAttributeSet attrs)
{
var tag = ParseAttributes (view.Context, attrs);
if (tag == null)
return;
if (view.GetBindingTag () != null) {
MvxBindingTrace.Trace (MvxTraceLevel.Warning,
"Trying to attach binding information to already configured view. Using binding elements on <fragment> tag?");
return;
}
view.SetBindingTag (tag);
}