public DockPanel CreateChartDescriptorPanel()
        {
            Label dateTimeFromLabel = new Label {Content = "DateTime from:"};
            DateTimePicker dateTimePickerFrom = new DateTimePicker
            {
                DataContext = _chartDescriptor.DateTimeFrom,
                Value = _chartDescriptor.DateTimeFrom
            };
            dateTimePickerFrom.SetBinding(InputBase.TextProperty, new Binding("DateTimeFrom")
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            dateTimePickerFrom.ValueChanged += delegate
            {
                if (dateTimePickerFrom.Value != null)
                {
                    _chartDescriptor.DateTimeFrom = (DateTime) dateTimePickerFrom.Value;
                }
            };

            Label dateTimeToLabel = new Label {Content = "DateTime to:"};
            DateTimePicker dateTimePickerTo = new DateTimePicker
            {
                DataContext = _chartDescriptor.DateTimeTo,
                Value = _chartDescriptor.DateTimeFrom
            };
            dateTimePickerFrom.SetBinding(InputBase.TextProperty, new Binding("DateTimeTo")
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            dateTimePickerTo.ValueChanged += delegate
            {
                if (dateTimePickerTo.Value != null)
                {
                    _chartDescriptor.DateTimeTo = (DateTime) dateTimePickerTo.Value;
                }
            };

            Label numberTextBoxLabel = new Label {Content = "Number of points"};
            TextBox numberTextBox = new TextBox
            {
                DataContext = _chartDescriptor.Number,
                Text = _chartDescriptor.Number.ToString(),
                Width = 40
            };
            numberTextBox.TextChanged += delegate
            {
                try
                {
                    _chartDescriptor.Number = Convert.ToInt32(numberTextBox.Text);
                }
                catch (Exception)
                {
                    // ignored
                }
            };

            Label onlyCriticalCheckBoxLabel = new Label {Content = "Show only critical"};
            CheckBox onlyCriticalCheckBox = new CheckBox
            {
                DataContext = _chartDescriptor.OnlyCritical,
                VerticalAlignment = VerticalAlignment.Center
            };
            onlyCriticalCheckBox.Checked += delegate
            {
                if (onlyCriticalCheckBox.IsChecked != null && onlyCriticalCheckBox.IsChecked.Value)
                {
                    _chartDescriptor.OnlyCritical = true;
                }
            };
            onlyCriticalCheckBox.Unchecked += delegate
            {
                if (onlyCriticalCheckBox.IsChecked != null && !onlyCriticalCheckBox.IsChecked.Value)
                {
                    _chartDescriptor.OnlyCritical = false;
                }
            };

            DockPanel chartDescriptorPanel = new DockPanel
            {
                Name = _chartDescriptor.MeasurableType
            };

            chartDescriptorPanel.Children.Add(dateTimeFromLabel);
            chartDescriptorPanel.Children.Add(dateTimePickerFrom);
            chartDescriptorPanel.Children.Add(dateTimeToLabel);
            chartDescriptorPanel.Children.Add(dateTimePickerTo);
            chartDescriptorPanel.Children.Add(numberTextBoxLabel);
            chartDescriptorPanel.Children.Add(numberTextBox);
            chartDescriptorPanel.Children.Add(onlyCriticalCheckBoxLabel);
            chartDescriptorPanel.Children.Add(onlyCriticalCheckBox);

            return chartDescriptorPanel;
        }
        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;
        }