Browse Source
private TimeSpan _timeSpan;
[Editor(typeof(MyCustomEditor), typeof(MyCustomEditor))]
public TimeSpan TimeSpan
{
get { return _timeSpan; }
set { _timeSpan = value; }
}
public class MyCustomEditor : ITypeEditor
{
public FrameworkElement ResolveEditor(PropertyItem propertyItem)
{
TextBox editor = new TextBox();
Binding binding = new Binding("Value"); //bind to the Value property of the PropertyItem instance
binding.Source = propertyItem;
binding.Mode = propertyItem.IsWriteable ? BindingMode.TwoWay : BindingMode.OneWay;
BindingOperations.SetBinding(editor, TextBox.TextProperty, binding);
return editor;
}
}
pull/1645/head
3 changed files with 6 additions and 23 deletions
@ -1,18 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Attributes |
|||
{ |
|||
public class TypeEditorAttribute : Attribute |
|||
{ |
|||
public Type Type { get; set; } |
|||
|
|||
public TypeEditorAttribute(Type type) |
|||
{ |
|||
var valueSourceInterface = type.GetInterface("Microsoft.Windows.Controls.PropertyGrid.Editors.ITypeEditor"); |
|||
if (valueSourceInterface == null) |
|||
throw new ArgumentException("Type must implement the ITypeEditor interface.", "type"); |
|||
|
|||
Type = type; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue