12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using PDF_Office.Model.From;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace PDF_Office.CustomControl.Form
- {
- /// <summary>
- /// FormFieldCombox.xaml 的交互逻辑
- /// 用于表单显示字段的下拉控件
- /// </summary>
- public partial class FormFieldCombox : UserControl
- {
- public FormFieldCombox()
- {
- InitializeComponent();
- InitCombox();
- }
- public FormFieldType Type
- {
- get { return (FormFieldType)GetValue(TypeProperty); }
- set { SetValue(TypeProperty, value); }
- }
- // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty TypeProperty =
- DependencyProperty.Register("Type", typeof(FormFieldType), typeof(FormFieldCombox), new PropertyMetadata(FormFieldType.visible, FormFieldTypePropertyChanged));
- private static void FormFieldTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var control = d as FormFieldCombox;
- var type = (FormFieldType)e.NewValue;
- if (control != null)
- {
- control.Combox.SelectedIndex = (int)type;
- }
- }
- public FormFieldType SetType
- {
- get { return (FormFieldType)GetValue(SetTypeProperty); }
- set { SetValue(SetTypeProperty, value); }
- }
- // Using a DependencyProperty as the backing store for SetType. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty SetTypeProperty =
- DependencyProperty.Register("SetType", typeof(FormFieldType), typeof(FormFieldCombox), new PropertyMetadata(FormFieldType.visible,(d,e)=> {
- (d as FormFieldCombox).SetIndexBySetType((FormFieldType)e.NewValue);
- }));
- /// <summary>
- /// 根据settype 设置combox索引
- /// </summary>
- private void SetIndexBySetType(FormFieldType type)
- {
- Combox.SelectedIndex=(int)type;
- }
- private void InitCombox()
- {
- List<string> list = new List<string>();
- list.Add("可见");
- list.Add("隐藏");
- list.Add("可见但不可打印");
- list.Add("隐藏但可打印");
- Combox.ItemsSource = list;
- }
- private void Combox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- Type = (FormFieldType)Combox.SelectedIndex;
- }
- }
- }
|