/// <summary>
        /// Control loaded.
        /// </summary>
        void UnitTextBoxEditor_Loaded(object sender, RoutedEventArgs e)
        {
            Xceed.Wpf.DataGrid.CellContentPresenter cellContentPresenter = this.VisualParent as Xceed.Wpf.DataGrid.CellContentPresenter;
            Xceed.Wpf.DataGrid.DataCell             dataCell             = cellContentPresenter.TemplatedParent as Xceed.Wpf.DataGrid.DataCell;
            string columnName = dataCell.ParentColumn.FieldName;

            ESRI.ArcLogistics.Data.DataObject dataObject = dataCell.ParentRow.DataContext as ESRI.ArcLogistics.Data.DataObject;

            if (dataObject != null)
            {
                Type type = dataObject.GetType();

                PropertyInfo property = type.GetProperty(columnName);
                if (property != null)
                {
                    Attribute attr = Attribute.GetCustomAttribute(property, typeof(UnitPropertyAttribute));

                    UnitPropertyAttribute unitAttribute = (UnitPropertyAttribute)attr;

                    _typeConverter = TypeDescriptor.GetConverter(property.PropertyType);

                    _displayUnits = (RegionInfo.CurrentRegion.IsMetric) ? unitAttribute.DisplayUnitMetric : unitAttribute.DisplayUnitUS;
                    _valueUnits   = unitAttribute.ValueUnits;
                }

                _inited = true;

                _SetTextToInnerTextBox();
            }
            else
            {
                // If this is not DataObject
                Break breakObject = dataCell.ParentRow.DataContext as Break;
                if (breakObject != null)
                {
                    // If this is Break. Get it`s type and initiate control in a proper way.
                    Type         type     = breakObject.GetType();
                    PropertyInfo property = type.GetProperty(columnName);
                    if (property != null)
                    {
                        Attribute attr = Attribute.GetCustomAttribute(property, typeof(UnitPropertyAttribute));

                        UnitPropertyAttribute unitAttribute = (UnitPropertyAttribute)attr;

                        _typeConverter = TypeDescriptor.GetConverter(property.PropertyType);

                        _displayUnits = (RegionInfo.CurrentRegion.IsMetric) ? unitAttribute.DisplayUnitMetric : unitAttribute.DisplayUnitUS;
                        _valueUnits   = unitAttribute.ValueUnits;
                    }

                    _inited = true;

                    _SetTextToInnerTextBox();
                }
            }
        }
        /// <summary>
        /// Initialize control.
        /// </summary>
        private void _Init()
        {
            Xceed.Wpf.DataGrid.CellContentPresenter cellContentPresenter = this.VisualParent as Xceed.Wpf.DataGrid.CellContentPresenter;
            if (cellContentPresenter == null)
            {
                return;
            }

            Xceed.Wpf.DataGrid.DataCell dataCell = cellContentPresenter.TemplatedParent as Xceed.Wpf.DataGrid.DataCell;
            string columnName = dataCell.ParentColumn.FieldName;

            ESRI.ArcLogistics.Data.DataObject dataObject = dataCell.ParentRow.DataContext as ESRI.ArcLogistics.Data.DataObject;

            if (dataObject != null)
            {
                int capacityPropertyIndex = Capacities.GetCapacityPropertyIndex(columnName);
                if (capacityPropertyIndex != -1)
                {
                    CapacityInfo capacityInfo = App.Current.Project.CapacitiesInfo[capacityPropertyIndex];
                    if (RegionInfo.CurrentRegion.IsMetric)
                    {
                        _displayUnits = capacityInfo.DisplayUnitMetric;
                    }
                    else
                    {
                        _displayUnits = capacityInfo.DisplayUnitUS;
                    }

                    _valueUnits = _displayUnits;
                }
                else
                {
                    Type         type     = dataObject.GetType();
                    PropertyInfo property = type.GetProperty(columnName);

                    UnitPropertyAttribute unitAttribute = (UnitPropertyAttribute)Attribute.GetCustomAttribute(property, typeof(UnitPropertyAttribute));

                    _displayUnits = (RegionInfo.CurrentRegion.IsMetric) ? unitAttribute.DisplayUnitMetric : unitAttribute.DisplayUnitUS;
                    _valueUnits   = unitAttribute.ValueUnits;
                }

                _TextBox.Text = UnitFormatter.Format(0.0, _displayUnits);

                _inited = true;

                _SetTextToInnerTextBox();
            }
            else
            {
                // If this is not DataObject
                Break breakObject = dataCell.ParentRow.DataContext as Break;
                if (breakObject != null)
                {
                    // If this is Break. Get it`s type and initiate control in a proper way.
                    Type type = breakObject.GetType();

                    PropertyInfo property = type.GetProperty(columnName);
                    if (property != null)
                    {
                        Attribute attr = Attribute.GetCustomAttribute(property, typeof(UnitPropertyAttribute));

                        UnitPropertyAttribute unitAttribute = (UnitPropertyAttribute)attr;

                        _displayUnits = (RegionInfo.CurrentRegion.IsMetric) ? unitAttribute.DisplayUnitMetric : unitAttribute.DisplayUnitUS;
                        _valueUnits   = unitAttribute.ValueUnits;
                    }

                    _TextBox.Text = UnitFormatter.Format(0.0, _displayUnits);

                    _inited = true;

                    _SetTextToInnerTextBox();
                }
            }
        }