Inheritance: DecimalUpDown
        private static void OnIsOpenChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            CalculatorUpDown calculatorUpDown = o as CalculatorUpDown;

            if (calculatorUpDown != null)
            {
                calculatorUpDown.OnIsOpenChanged(( bool )e.OldValue, ( bool )e.NewValue);
            }
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this._demo = ((Xceed.Wpf.Toolkit.LiveExplorer.Samples.Numeric.Views.NumericView)(target));
                return;

            case 2:
                this._doubleUpDown = ((Xceed.Wpf.Toolkit.DoubleUpDown)(target));
                return;

            case 3:
                this._enterClosesCalculator = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 4:
                this._calculatorUpDown = ((Xceed.Wpf.Toolkit.CalculatorUpDown)(target));
                return;
            }
            this._contentLoaded = true;
        }
        public FrameworkElement CreateExtendedToolkitControl(PropertyDefinition propertyDefinition, string bindingPath)
        {
            var propertyType = propertyDefinition.PropertyType;
            if (propertyType.Is(typeof(DateTime)))
            {
                var c = new DateTimePicker()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(DateTimePicker.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(TimeSpan)))
            {
                var c = new TimeSpanUpDown()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(TimeSpanUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(int)) || propertyType.Is(typeof(int?)))
            {
                var c = new CalculatorUpDown()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Minimum = int.MinValue,
                    Maximum = int.MaxValue,
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(uint)) || propertyType.Is(typeof(uint?)))
            {
                var c = new CalculatorUpDown()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Minimum = 0,
                    Maximum = uint.MaxValue,
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(decimal)) || propertyType.Is(typeof(decimal?)))
            {
                var c = new CalculatorUpDown()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Minimum = decimal.MinValue,
                    Maximum = decimal.MaxValue,
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(Single)) || propertyType.Is(typeof(Single?)))
            {
                var c = new CalculatorUpDown()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Minimum = decimal.MinValue,
                    Maximum = decimal.MaxValue,
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(double)) || propertyType.Is(typeof(double?)))
            {
                var c = new CalculatorUpDown()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Minimum = decimal.MinValue,
                    Maximum = decimal.MaxValue,
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(Brush)))
            {
                var c = new ColorBox.ColorBox()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                };
                c.SetBinding(ColorBox.ColorBox.BrushProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(Guid)) || propertyType.Is(typeof(Guid?)))
            {
                var c = new MaskedTextBox()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Mask = "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA",
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(MaskedTextBox.TextProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            if (propertyType.Is(typeof(char)) || propertyType.Is(typeof(char?)))
            {
                var c = new MaskedTextBox()
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Mask = "&",
                    IsReadOnly = propertyDefinition.IsReadOnly
                };
                c.SetBinding(MaskedTextBox.TextProperty, propertyDefinition.CreateBinding(bindingPath));
                return c;
            }

            return null;
        }
        //Sets up the controls for the custom control
        private void InitializeControl()
        {
            int i = 0;

            foreach (CCustomLine cl in this.CustomFields.CustomLines)
            {
                //Add new row to the grid
                RowDefinition rd = new RowDefinition();
                rd.MinHeight = 30;
                rd.MaxHeight = 30;
                ControlGrid.RowDefinitions.Add(rd);

                System.Windows.Controls.TextBlock tb = new TextBlock();
                tb.SetValue(Grid.RowProperty, i);
                tb.SetValue(Grid.ColumnProperty, 0);
                tb.TextAlignment = TextAlignment.Right;
                tb.Margin = new Thickness(3);
                tb.Text = cl.Caption;
                ControlGrid.Children.Add(tb);

                 switch (cl.DataType)
                {
                    case CCustomLine.CustDataType.cdText:

                        if (cl.IsList)
                        {
                            System.Windows.Controls.ComboBox cbx = new ComboBox();
                            cbx.SetValue(Grid.RowProperty, i);
                            cbx.SetValue(Grid.ColumnProperty, 1);
                            cbx.Margin = new Thickness(3);
                            cbx.Tag = cl.Caption;
                            cbx.SelectionChanged += CustomDataChanged;

                            foreach (string sl in cl.PickList)
                            {
                                cbx.Items.Add(sl);
                            }
                            ControlGrid.Children.Add(cbx);
                        }
                        else
                        {
                            System.Windows.Controls.TextBox tbx = new TextBox();
                            tbx.SetValue(Grid.RowProperty, i);
                            tbx.SetValue(Grid.ColumnProperty, 1);
                            tbx.Margin = new Thickness(3);
                            tbx.Tag = cl.Caption;
                            tbx.Text = cl.Caption;
                            tbx.TextChanged += CustomDataChanged;
                            ControlGrid.Children.Add(tbx);
                        }
                        break;

                    case CCustomLine.CustDataType.cdDate:

                        System.Windows.Controls.DatePicker dtp = new DatePicker();
                        dtp.SetValue(Grid.RowProperty, i);
                        dtp.SetValue(Grid.ColumnProperty, 1);
                        dtp.Margin = new Thickness(3);
                        dtp.Tag = cl.Caption;
                        dtp.SelectedDateChanged += CustomDataChanged;
                        ControlGrid.Children.Add(dtp);
                        break;

                    case CCustomLine.CustDataType.cdInteger:

                        Xceed.Wpf.Toolkit.IntegerUpDown iud = new IntegerUpDown();
                        iud.SetValue(Grid.RowProperty, i);
                        iud.SetValue(Grid.ColumnProperty, 1);
                        iud.Margin = new Thickness(3);
                        iud.Tag = cl.Caption;
                        iud.ValueChanged += CustomDataChanged;
                        ControlGrid.Children.Add(iud);
                        break;

                    case CCustomLine.CustDataType.cdNumber:

                        Xceed.Wpf.Toolkit.CalculatorUpDown dud = new CalculatorUpDown();
                        dud.SetValue(Grid.RowProperty, i);
                        dud.SetValue(Grid.ColumnProperty, 1);
                        dud.Margin = new Thickness(3);
                        dud.Tag = cl.Caption;
                        dud.ValueChanged += CustomDataChanged;
                        ControlGrid.Children.Add(dud);
                        break;

                    case CCustomLine.CustDataType.cdCurrency:

                        Xceed.Wpf.Toolkit.CalculatorUpDown cud = new CalculatorUpDown();
                        cud.SetValue(Grid.RowProperty, i);
                        cud.SetValue(Grid.ColumnProperty, 1);
                        cud.Margin = new Thickness(3);
                        cud.Tag = cl.Caption;
                        cud.FormatString = "C2";
                        cud.ValueChanged += CustomDataChanged;
                        ControlGrid.Children.Add(cud);
                        break;

                    case CCustomLine.CustDataType.cdBoolean:

                        System.Windows.Controls.CheckBox chkb = new CheckBox();
                        chkb.SetValue(Grid.RowProperty, i);
                        chkb.SetValue(Grid.ColumnProperty, 1);
                        chkb.Margin = new Thickness(3); //Do we need this?
                        chkb.Tag = cl.Caption;
                        chkb.Checked += CustomDataChanged;
                        ControlGrid.Children.Add(chkb);
                        break;

                    case CCustomLine.CustDataType.cdBusinessLink:
                    case CCustomLine.CustDataType.cdInspectorLink:

                        System.Windows.Controls.TextBlock LinkTB = new TextBlock();
                        LinkTB.SetValue(Grid.RowProperty, i);
                        LinkTB.SetValue(Grid.ColumnProperty, 1);
                        LinkTB.Margin = new Thickness(3); //Do we need this?
                        LinkTB.Tag = cl.Caption;
                        ControlGrid.Children.Add(LinkTB);
                        break;

                }

                i++;
            }
        }