add PropertyGrid Demo
This commit is contained in:
1 parent
0a9d95fafd
commit
f7a39f3d32
18 files changed
+320
-82
No files matched your search
@@ -0,0 +1,19 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class DatePropertyEditor : PropertyEditorBase
|
||||
{
|
||||
public override FrameworkElement CreateElement(PropertyItem propertyItem)
|
||||
{
|
||||
var picker = new DateTimePicker
|
||||
{
|
||||
IsEnabled = !propertyItem.IsReadOnly
|
||||
};
|
||||
|
||||
picker.SetBinding(System.Windows.Controls.DatePicker.SelectedDateProperty, CreateBinding(propertyItem));
|
||||
|
||||
return picker;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class IntegerPropertyEditor : PropertyEditorBase
|
||||
public class NumberPropertyEditor : PropertyEditorBase
|
||||
{
|
||||
public IntegerPropertyEditor(double minimum, double maximum)
|
||||
public NumberPropertyEditor(double minimum, double maximum)
|
||||
{
|
||||
Minimum = minimum;
|
||||
Maximum = maximum;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class NumberPropertyEditor : PropertyEditorBase
|
||||
{
|
||||
public NumberPropertyEditor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public NumberPropertyEditor(double minimum, double maximum)
|
||||
{
|
||||
Minimum = minimum;
|
||||
Maximum = maximum;
|
||||
}
|
||||
|
||||
public double Minimum { get; set; }
|
||||
|
||||
public double Maximum { get; set; }
|
||||
|
||||
public override FrameworkElement CreateElement(PropertyItem propertyItem)
|
||||
{
|
||||
var numericUpDown = new NumericUpDown
|
||||
{
|
||||
IsReadOnly = propertyItem.IsReadOnly,
|
||||
Minimum = Minimum,
|
||||
Maximum = Maximum
|
||||
};
|
||||
|
||||
numericUpDown.SetBinding(NumericUpDown.ValueProperty, CreateBinding(propertyItem));
|
||||
|
||||
return numericUpDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class PlainTextPropertyEditor : PropertyEditorBase
|
||||
{
|
||||
public override FrameworkElement CreateElement(PropertyItem propertyItem)
|
||||
{
|
||||
var textbox = new System.Windows.Controls.TextBox
|
||||
{
|
||||
IsReadOnly = propertyItem.IsReadOnly
|
||||
};
|
||||
|
||||
textbox.SetBinding(System.Windows.Controls.TextBox.TextProperty, CreateBinding(propertyItem));
|
||||
|
||||
return textbox;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,12 @@ namespace HandyControl.Controls
|
||||
new Binding(propertyItem.PropertyName)
|
||||
{
|
||||
Source = propertyItem.Value,
|
||||
Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay,
|
||||
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
|
||||
Mode = GetBindingMode(),
|
||||
UpdateSourceTrigger = GetUpdateSourceTrigger()
|
||||
};
|
||||
|
||||
public virtual BindingMode GetBindingMode() => BindingMode.OneWay;
|
||||
|
||||
public virtual UpdateSourceTrigger GetUpdateSourceTrigger() => UpdateSourceTrigger.Default;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class StringPropertyEditor : PropertyEditorBase
|
||||
public class PlainTextPropertyEditor : PropertyEditorBase
|
||||
{
|
||||
public override FrameworkElement CreateElement(PropertyItem propertyItem)
|
||||
{
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ using HandyControl.Tools;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class BooleanPropertyEditor : PropertyEditorBase
|
||||
public class SwitchPropertyEditor : PropertyEditorBase
|
||||
{
|
||||
public override FrameworkElement CreateElement(PropertyItem propertyItem)
|
||||
{
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class TimePropertyEditor : PropertyEditorBase
|
||||
{
|
||||
public override FrameworkElement CreateElement(PropertyItem propertyItem)
|
||||
{
|
||||
var picker = new DateTimePicker
|
||||
{
|
||||
IsEnabled = !propertyItem.IsReadOnly
|
||||
};
|
||||
|
||||
picker.SetBinding(TimePicker.SelectedTimeProperty, CreateBinding(propertyItem));
|
||||
|
||||
return picker;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user