private void Window_Loaded(object sender, RoutedEventArgs e) { var lst = JWCControlFactory.GetAllControls(); foreach (var pai in lst) { CtrlListboxItem item = new CtrlListboxItem(); item.FullName = pai.Key; Type jctp = pai.Value; JWCControlDescAttribute attr = (JWCControlDescAttribute)Attribute.GetCustomAttribute(jctp, typeof(JWCControlDescAttribute)); if (attr == null) { item.FName = item.FullName; } else { item.FName = attr.FriendlyName; } if (attr == null || attr.Description == null || attr.Description.Length < 1) { item.Description = "该控件无描述文本"; } else { item.Description = attr.Description; } lst_ctrls.Items.Add(item); } }
void lst_ctrls_SelectionChanged(object sender, SelectionChangedEventArgs e) { CtrlListboxItem item = (CtrlListboxItem)lst_ctrls.SelectedItem; lbl_name.Content = item.FName; lbl_fullname.Content = item.FullName; txt_desc.Text = item.Description; }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (OnConfirmAdd != null) { CtrlListboxItem item = lst_ctrls.SelectedItem as CtrlListboxItem; if (item == null) { return; } JWCControl jc = JWCControlFactory.CreateInstance(item.FullName); jc.IsEditMode = true; jc.Init(true); OnConfirmAdd(jc); } }