ios - MvvmCross - 如何将 UIView.Layer.AnyProperty (Xamarin.iOS) 绑定(bind)到 View 模型上的属性?

标签 ios xamarin.ios xamarin mvvmcross

我在一个名为 BorderColor 的字符串类型的 View 模型上有一个属性,我尝试将它绑定(bind)到 UIView.Layer.BorderColor,这是绑定(bind)语法:

set.Bind (this.MyUIView).For ("Layer.BorderColor").To (t => t.BorderColor).WithConversion (new StringToColorConverter { ToCGColor = true });

但是,如果我说直接在 UIView 上绑定(bind)到 BackgroundColor 属性,它不起作用,它就像一个魅力。有人知道 MvvmCross 是否支持绑定(bind)到 Layer 属性?

我尝试了目标路径的不同变体,例如“Layer.BorderColor”,并强输入了 t=>Layer.BorderColor,没有运气。

最佳答案

来自 https://github.com/MvvmCross/MvvmCross/wiki/Databinding#fluent 的流畅绑定(bind)语法的描述

The fluent syntax provides a C# way to create bindings.

This syntax is generally done using the CreateBindingSet helper.

The syntax includes:

       Bind($ViewObject$) 

where $ViewObject$ is the view target for binding.

       For(v => v.$ViewProperty$) 

where $ViewProperty$ is the property on the view for binding.



所以......你可以尝试使用:
     set.Bind (this.MyUIView.Layer).For ("BorderColor")...

只要没有人更改 Layer,这应该可以工作。本身 - 如果您需要比这更复杂的绑定(bind),那么您需要创建一个自定义绑定(bind)(参见 N+1 系列中的示例)。

关于ios - MvvmCross - 如何将 UIView.Layer.AnyProperty (Xamarin.iOS) 绑定(bind)到 View 模型上的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26239110/

相关文章:

iphone - 构建失败,xcode 4.4中没有错误

android - 将 .NET Standard 类库转换为 native aar/jar

ios - Xamarin.iOS 中的 UITableViewController.RowsInSection(UITableView, int) 应该是什么?

ios - 如何从 UINavigationBar 中删除背景图像

c# - 连接到 Azure 数据库的 Azure Function App C# HTTP 触发器

xamarin - 为什么包名称在 Xamarin.Android 中加倍?

ios - 下载整个网站

ios - swift 不能用 String 调用 isKindOfClass

objective-c - 核心数据在以编程方式执行时不保存更新。

ios - 错误 MT2002 : Failed to resolve assembly: 'System.Drawing'