/// <summary> /// /// </summary> /// <param name="data"></param> /// <param name="idx"></param> /// <returns></returns> private View GetChild(object data) { View child = null; if (this.ItemTemplate != null || this.ItemTemplateSelector != null) { if (this.ItemTemplateSelector != null) { child = (View)this.ItemTemplateSelector.SelectTemplate(data, this).CreateContent(); } else if (this.ItemTemplate != null) { child = (View)this.ItemTemplate.CreateContent(); } if (child != null) { child.BindingContext = data; } } if (child == null) { child = new Label() { Text = "Not set ItemTemplate" } } ; child.BindingContext = data; child.SetBinding(TapBinder.CmdProperty, new Binding(nameof(this.ItemTapedCmd), source: this)); TapBinder.SetParam(child, data); TapBinder.SetWithFeedback(child, ItemWithFeedBack); return(child); }
private static void ItemWithFeedBackPropertyChanged(BindableObject bindable, object oldValue, object newValue) { var grid = (UniformGrid)bindable; foreach (var view in grid.Children) { TapBinder.SetWithFeedback(view, (bool)newValue); } }
private static void ItemTapedCmdChanged(BindableObject bindable, object oldValue, object newValue) { var repeater = (Repeater)bindable; var flag = (newValue != null || repeater.ItemTapedCmd != null); foreach (var v in repeater.Container.Children) { TapBinder.SetWithFeedback(v, flag); } }
private static void ItemTapedCmdChanged(BindableObject bindable, object oldValue, object newValue) { var g = (UniformGrid)bindable; var flag = (newValue != null || g.ItemTapedCmd != null); foreach (var v in g.Children) { TapBinder.SetWithFeedback(v, flag); } }
/// <summary> /// 从模板/模板选择器创建子视图 /// </summary> /// <param name="data"></param> /// <returns></returns> private View GetChildView(object data) { View view = null; if (this.ItemTemplate != null || this.ItemTemplateSelector != null) { if (this.ItemTemplateSelector != null) { // SelectTemplate 的第二个参数,即 TemplateSelector 的 OnSelectTemplate 方法的 container 参数 view = (View)this.ItemTemplateSelector.SelectTemplate(data, this).CreateContent(); } else if (this.ItemTemplate != null) { view = (View)this.ItemTemplate.CreateContent(); } if (view != null) { view.BindingContext = data; TapBinder.SetCmd(view, this.TapCmd); TapBinder.SetParam(view, data); if (this.ItemTaped == null && this.ItemTapedCmd == null) { TapBinder.SetWithFeedback(view, false); } } } if (view == null) { view = new Label() { Text = "111" } } ; return(view); }