//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++;
            }
        }