protected override FrameworkElement CreateDynamicEditingElement(Entity curEntity) { var value = this.PropertyValue; //支持两种属性类型:DateRange,String,所以这里使用这个变量进行分辨 var useDateRangeType = this.Meta.PropertyMeta.Runtime.PropertyType == typeof(DateRange); var range = useDateRangeType ? new DateRange(value as DateRange) : DateRange.Parse(value != null ? value as string : string.Empty); var control = new DateRangePropertyEditorControl(range); control.Confirm += (oo, ee) => { if (useDateRangeType) { var raw = value as DateRange; raw.BeginValue = ee.Range.BeginValue; raw.EndValue = ee.Range.EndValue; } else { this.PropertyValue = ee.Range.ToString(); } }; control.KeyDown += (oo, ee) => { if (ee.Key == Key.Enter) { FocusNavigationDirection focusDirection = FocusNavigationDirection.Next; TraversalRequest request = new TraversalRequest(focusDirection); control.MoveFocus(request); } }; this.AddReadOnlyComponent(control); this.SetAutomationElement(control); return(control); }
protected override FrameworkElement CreateDynamicEditingElement(Entity curEntity) { var value = this.PropertyValue; //支持两种属性类型:DateRange,String,所以这里使用这个变量进行分辨 var useDateRangeType = this.Meta.PropertyMeta.Runtime.PropertyType == typeof(DateRange); var range = useDateRangeType ? new DateRange(value as DateRange) : DateRange.Parse(value != null ? value as string : string.Empty); var control = new DateRangePropertyEditorControl(range); control.Confirm += (oo, ee) => { if (useDateRangeType) { var raw = value as DateRange; raw.BeginValue = ee.Range.BeginValue; raw.EndValue = ee.Range.EndValue; } else { this.PropertyValue = ee.Range.ToString(); } }; control.KeyDown += (oo, ee) => { if (ee.Key == Key.Enter) { FocusNavigationDirection focusDirection = FocusNavigationDirection.Next; TraversalRequest request = new TraversalRequest(focusDirection); control.MoveFocus(request); } }; this.AddReadOnlyComponent(control); this.SetAutomationElement(control); return control; }