private void Content_Type_ItemCreated(GameObject obj) { obj.GetClickedEventHelper().Clicked += (go) => { var type = (go.GetDataContextValue() as DesignerDataLogic).Type; var dialogPanel = DialogPanel_Rows.gameObject; dialogPanel.SetActive(true); var dataType = typeof(DataEntityTemplate<>).MakeGenericType(type); var allData = dataType.InvokeMember("GetAllData", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, null) as IEnumerable; var collection = new NotifyCollection<DesignerDataLogic>(); int i = 0; foreach (var data in allData) { collection.Add(new DesignerDataLogic() { Index = i, Row = data }); ++i; } Content_Rows.ItemCreated += Content_Rows_ItemCreated; Content_Rows.ItemTemplate = buttonPrefab; Content_Rows.SourceCollection = collection; }; }
private void Content_Rows_ItemCreated(GameObject obj) { obj.GetClickedEventHelper().Clicked += (go) => { var ins = (go.GetDataContextValue() as DesignerDataLogic).Row; var dialogPanel = DialogPanel_RowDetail.gameObject; dialogPanel.SetActive(true); var collection = new NotifyCollection<DesignerDataLogic>(); foreach (var pro in ins.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) { if (pro.GetCustomAttributes(typeof(ColumnNameAttribute), false).Length <= 0) continue; collection.Add(new DesignerDataLogic() { TextAlignment = TextAnchor.MiddleRight, DisplayText = pro.Name + " = " }); string v = pro.GetValue(ins, null).ToString(); if (string.IsNullOrEmpty(v)) v = "\"\""; collection.Add(new DesignerDataLogic() { TextAlignment = TextAnchor.MiddleLeft, DisplayText = v }); } Content_RowDetail.ItemTemplate = textPrefab; Content_RowDetail.SourceCollection = collection; }; }