Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: PropertyGrid edit defaults editors

$
0
0
Like this
  void RegisterControl(Binding binding, object val)
        {
            UIElement ctl = null;
            var type = val.GetType();
            if (type == typeof(double))
            {
                ctl = new DoubleUpDown();
                BindingOperations.SetBinding(ctl, DoubleUpDown.ValueProperty, binding);
            }
            else if (type == typeof(int))
            {
                ctl = new IntegerUpDown();
                BindingOperations.SetBinding(ctl, IntegerUpDown.ValueProperty, binding);
            }
            else if (type == typeof(long))
            {
                ctl = new LongUpDown();
                BindingOperations.SetBinding(ctl, LongUpDown.ValueProperty, binding);
            }
            else if (type == typeof(byte))
            {
                ctl = new ByteUpDown();
                BindingOperations.SetBinding(ctl, ByteUpDown.ValueProperty, binding);
            }
            else if (type == typeof(short))
            {
                ctl = new ShortUpDown();
                BindingOperations.SetBinding(ctl, ShortUpDown.ValueProperty, binding);
            }
            
            if (ctl != null)
                _grid.Children.Add(ctl);

        }
It's ugly but it works...

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>