Setting Minimum and Maximum on IntegerUpDownEditor

Apr 23, 2012 at 7:10 PM

Hello all,

How do you set the Minimum and Maximum properties on an IntegerUpDown when you want to use IntegerUpDownEditor as the Editor?

Apr 23, 2012 at 9:07 PM
Edited Apr 23, 2012 at 9:24 PM

I was able to get this to work by creating a couple custom attributes and applying them to the class property and then subclassing the IntegerUpDownEditor and overriding the ResolveEditor method to look for the custom attributes on the propertyItem.Instance property referenced by propertyItem.BindingPath. But is this the best way to handle this situation?

    public class IntegerUpDownEditorEx : Xceed.Wpf.Toolkit.PropertyGrid.Editors.IntegerUpDownEditor
        public IntegerUpDownEditorEx()
            : base()

        public override System.Windows.FrameworkElement ResolveEditor(Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem)
            System.Windows.FrameworkElement frameworkElement = base.ResolveEditor(propertyItem);

            foreach (object attribute in propertyItem.Instance.GetType().GetProperty(propertyItem.BindingPath).GetCustomAttributes(true))
                if (attribute is IntegerUpDownEditorMinimumAttribute)
                    this.Editor.Minimum = (attribute as IntegerUpDownEditorMinimumAttribute).Minimum;
                else if (attribute is IntegerUpDownEditorMaximumAttribute)
                    this.Editor.Maximum = (attribute as IntegerUpDownEditorMaximumAttribute).Maximum;
            return frameworkElement;




public class IntegerUpDownEditorMinimumAttribute : Attribute { public readonly int Minimum; public IntegerUpDownEditorMinimumAttribute(int Minimum) : base() { this.Minimum = Minimum; } }


public class IntegerUpDownEditorMaximumAttribute : Attribute { public readonly int Maximum; public IntegerUpDownEditorMaximumAttribute(int maximum) : base() { this.Maximum = maximum; } }

Apr 23, 2012 at 10:34 PM

I was able to assign the minimum and maximum values in xaml as follows:

<xctk:PropertyGrid DockPanel.Dock="Top" Name="propertyGrid" HorizontalAlignment="Stretch" Margin="0,6,6,6">
                <xctk:PropertyDefinition Name="Age" />
                    <xctk:IntegerUpDown Minimum="0" Maximum="125" Text="{Binding Value}" />