
IsVisible="{Binding Path=UserContext.IsLoggedOut}" 是 – 该属性绑定到视图模型的子对象.现在要么在Xamarin Forms中不支持,要么我错过了一个技巧.
如果在WPF中支持Xamarin不支持,那么我们应该做些什么来传播嵌套对象?展平视图模型正在让我写出令人难以置信的代码和大量代码.
解决方法 支持嵌套属性,就像其他非常复杂的表达式一样:你可以测试一下:
XAML
<StackLayout Spacing="20"> <StackLayout OrIEntation="Horizontal"> <Label Text="SubpropertIEs: " HorizontalOptions="FillAndExpand" FontSize="15"></Label> <Label Text="{Binding Item.SubItem.Text}" HorizontalOptions="FillAndExpand" FontSize="15"></Label> </StackLayout> <StackLayout OrIEntation="Horizontal"> <Label Text="Indexer: " HorizontalOptions="FillAndExpand" FontSize="15"></Label> <Label Text="{Binding Item.Dictionary[key].Text}" HorizontalOptions="FillAndExpand" FontSize="15"></Label> </StackLayout> <StackLayout OrIEntation="Horizontal"> <Label Text="Array Indexer: " HorizontalOptions="FillAndExpand" FontSize="15"></Label> <Label Text="{Binding Item.Array[1].Text}" HorizontalOptions="FillAndExpand" FontSize="15"></Label> </StackLayout></StackLayout> 页
public partial class Page2 : ContentPage{ public Itemmodel Item { get; } public Page2() { InitializeComponent(); Item = new Itemmodel(); BindingContext = this; }}public class Itemmodel{ public ItemSubModel SubItem { get; set; } public Dictionary<string,ItemSubModel> Dictionary { get; set; } public ItemSubModel[] Array { get; set; } public Itemmodel() { SubItem = new ItemSubModel(); Dictionary = new Dictionary<string,ItemSubModel> { {"key",new ItemSubModel()} }; Array = new [] {new ItemSubModel(),new ItemSubModel() }; }}public class ItemSubModel{ public string Text { get; set; } = "Supported";} 结果
总结以上是内存溢出为你收集整理的数据绑定 – Xamarin表单数据绑定“.”分隔符全部内容,希望文章能够帮你解决数据绑定 – Xamarin表单数据绑定“.”分隔符所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)