private void AddChildControls()
        {
            this.ClipToBounds = true;

            //RadialGradientBrush radialBrush = new RadialGradientBrush(new GradientStopCollection(new GradientStop[]{
            //  new GradientStop(Colors.White, 0.59999999999999942),
            //  new GradientStop(Colors.Transparent, 1)}));

            Transform invertTransform = new ScaleTransform(1, -1);

            // Create the Grid
            _host = new Grid();
            _host.IsHitTestVisible = true;

            // Create the columns
            ColumnDefinition columnDef1 = new ColumnDefinition();
            ColumnDefinition columnDef2 = new ColumnDefinition();
            ColumnDefinition columnDef3 = new ColumnDefinition();

            columnDef1.Width = new GridLength(1, GridUnitType.Auto);
            columnDef2.Width = new GridLength(1, GridUnitType.Auto);
            columnDef3.Width = new GridLength(1, GridUnitType.Star);
            _host.ColumnDefinitions.Add(columnDef1);
            _host.ColumnDefinitions.Add(columnDef2);
            _host.ColumnDefinitions.Add(columnDef3);

            // Create the rows

            RowDefinition rowDef1 = new RowDefinition();
            RowDefinition rowDef2 = new RowDefinition();
            RowDefinition rowDef3 = new RowDefinition();
            RowDefinition rowDef4 = new RowDefinition();
            RowDefinition rowDef5 = new RowDefinition();
            RowDefinition rowDef6 = new RowDefinition();
            RowDefinition rowDef7 = new RowDefinition();

            rowDef1.Height = new GridLength(1, GridUnitType.Auto);
            rowDef2.Height = new GridLength(1, GridUnitType.Auto);
            rowDef3.Height = new GridLength(1, GridUnitType.Star);
            rowDef4.Height = new GridLength(1, GridUnitType.Auto);
            rowDef5.Height = new GridLength(1, GridUnitType.Auto);
            rowDef6.Height = new GridLength(1, GridUnitType.Auto);
            rowDef7.Height = new GridLength(1, GridUnitType.Auto);
            _host.RowDefinitions.Add(rowDef1);
            _host.RowDefinitions.Add(rowDef2);
            _host.RowDefinitions.Add(rowDef3);
            _host.RowDefinitions.Add(rowDef4);
            _host.RowDefinitions.Add(rowDef5);
            _host.RowDefinitions.Add(rowDef6);
            _host.RowDefinitions.Add(rowDef7);

            _xSlider = new Slider()
            {
                Margin           = new Thickness(-5, 0, -5, 0),
                IsHitTestVisible = true,
                Visibility       = System.Windows.Visibility.Collapsed
            };

            Grid.SetColumn(_xSlider, 2);
            Grid.SetRow(_xSlider, 5);
            _host.Children.Add(_xSlider);

            _titleBox = new TextBlock()
            {
                Margin = new Thickness(0),
                Text   = "Title",
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch,
                TextAlignment       = TextAlignment.Center,
                //Background = radialBrush,
                IsHitTestVisible = false,
                Visibility       = Visibility.Collapsed
            };
            Grid.SetColumn(_titleBox, 2);
            Grid.SetRow(_titleBox, 0);
            _host.Children.Add(_titleBox);

            _legendBox = new UniformWrapPanel()
            {
                Margin = new Thickness(5),
                //Background = new SolidColorBrush(Color.FromArgb(0x2F, 0, 0, 0)),
                IsHitTestVisible = false
            };
            Grid.SetColumn(_legendBox, 0);
            Grid.SetRow(_legendBox, 1);
            Grid.SetColumnSpan(_legendBox, 3);
            _host.Children.Add(_legendBox);

            _xTitleBar = new Rectangle()
            {
                Margin = new Thickness(0),
                //Fill = radialBrush,
                IsHitTestVisible = false
            };
            Grid.SetColumn(_xTitleBar, 0);
            Grid.SetRow(_xTitleBar, 4);
            Grid.SetColumnSpan(_xTitleBar, 3);
            _host.Children.Add(_xTitleBar);

            _yTitleBar = new Rectangle()
            {
                Margin = new Thickness(0),
                //Fill = radialBrush,
                IsHitTestVisible = false
            };
            Grid.SetColumn(_yTitleBar, 0);
            Grid.SetRow(_yTitleBar, 2);
            Grid.SetRowSpan(_yTitleBar, 3);
            _host.Children.Add(_yTitleBar);

            _xGridLineLabels = new Rectangle()
            {
                Margin           = new Thickness(2, 0, 0, 2),
                Fill             = Brushes.Transparent, // new SolidColorBrush(Color.FromArgb(127, 255, 255, 255)),
                IsHitTestVisible = false
            };
            Grid.SetColumn(_xGridLineLabels, 1);
            Grid.SetRow(_xGridLineLabels, 3);
            Grid.SetColumnSpan(_xGridLineLabels, 2);
            _host.Children.Add(_xGridLineLabels);

            _yGridLineLabels = new Rectangle()
            {
                Margin           = new Thickness(2, 0, 0, 2),
                Fill             = Brushes.Transparent, //new SolidColorBrush(Color.FromArgb(127, 255, 255, 255)),
                IsHitTestVisible = false
            };
            Grid.SetColumn(_yGridLineLabels, 1);
            Grid.SetRow(_yGridLineLabels, 2);
            Grid.SetRowSpan(_yGridLineLabels, 2);
            _host.Children.Add(_yGridLineLabels);


            var gridLineBorder = new Border()
            {
                Margin           = new Thickness(3),
                BorderThickness  = new Thickness(1),
                BorderBrush      = Brushes.LightGray,
                IsHitTestVisible = false
            };

            _gridLineCanvas = new GridLineCanvas()
            {
                Margin           = new Thickness(0),
                IsHitTestVisible = false
            };
            gridLineBorder.Child = _gridLineCanvas;
            Grid.SetColumn(gridLineBorder, 2);
            Grid.SetRow(gridLineBorder, 2);
            _host.Children.Add(gridLineBorder);

            _imageHost = new Image()
            {
                Margin  = new Thickness(0),
                Stretch = Stretch.None,
                RenderTransformOrigin = new Point(0.5, 0.5),
                RenderTransform       = invertTransform,
                HorizontalAlignment   = System.Windows.HorizontalAlignment.Left,
                VerticalAlignment     = System.Windows.VerticalAlignment.Top,
                IsHitTestVisible      = false
            };
            Grid.SetColumn(_imageHost, 2);
            Grid.SetRow(_imageHost, 2);
            _host.Children.Add(_imageHost);

            _cursorCoordinateCanvas = new CursorCoordinateCanvas()
            {
                Margin = new Thickness(0),
                RenderTransformOrigin = new Point(0.5, 0.5),
                RenderTransform       = invertTransform,
                ClipToBounds          = false,
                Background            = new SolidColorBrush(Colors.Transparent),
                IsHitTestVisible      = false
            };
            Grid.SetColumn(_cursorCoordinateCanvas, 2);
            Grid.SetRow(_cursorCoordinateCanvas, 2);
            // _host.Children.Add(_cursorCoordinateCanvas);

            _subNotes = new ListView()
            {
                FontSize    = 10,
                Visibility  = System.Windows.Visibility.Collapsed,
                Background  = new SolidColorBrush(Colors.Transparent),
                BorderBrush = new SolidColorBrush(Colors.Transparent),
            };

            Border subNotesBorder = new Border()
            {
                Background       = new SolidColorBrush(Color.FromArgb(0x20, 0, 0, 0)),
                BorderBrush      = new SolidColorBrush(Colors.Transparent),
                BorderThickness  = new Thickness(0),
                Padding          = new Thickness(0),
                CornerRadius     = new CornerRadius(8),
                IsHitTestVisible = false
            };

            Grid.SetColumn(subNotesBorder, 0);
            Grid.SetRow(subNotesBorder, 6);
            Grid.SetColumnSpan(subNotesBorder, 3);
            subNotesBorder.Child = _subNotes;
            _host.Children.Add(subNotesBorder);

            DockPanel.SetDock(_host, Dock.Left);
            this.Children.Add(_host);
        }
    private void AddChildControls() {

      this.ClipToBounds = true;

      //RadialGradientBrush radialBrush = new RadialGradientBrush(new GradientStopCollection(new GradientStop[]{
      //  new GradientStop(Colors.White, 0.59999999999999942),
      //  new GradientStop(Colors.Transparent, 1)}));

      Transform invertTransform = new ScaleTransform(1, -1);

      // Create the Grid
      _host = new Grid();
      _host.IsHitTestVisible = true;

      // Create the columns
      ColumnDefinition columnDef1 = new ColumnDefinition();
      ColumnDefinition columnDef2 = new ColumnDefinition();
      ColumnDefinition columnDef3 = new ColumnDefinition();
      columnDef1.Width = new GridLength(1, GridUnitType.Auto);
      columnDef2.Width = new GridLength(1, GridUnitType.Auto);
      columnDef3.Width = new GridLength(1, GridUnitType.Star);
      _host.ColumnDefinitions.Add(columnDef1);
      _host.ColumnDefinitions.Add(columnDef2);
      _host.ColumnDefinitions.Add(columnDef3);

      // Create the rows

      RowDefinition rowDef1 = new RowDefinition();
      RowDefinition rowDef2 = new RowDefinition();
      RowDefinition rowDef3 = new RowDefinition();
      RowDefinition rowDef4 = new RowDefinition();
      RowDefinition rowDef5 = new RowDefinition();
      RowDefinition rowDef6 = new RowDefinition();
      RowDefinition rowDef7 = new RowDefinition();
      rowDef1.Height = new GridLength(1, GridUnitType.Auto);
      rowDef2.Height = new GridLength(1, GridUnitType.Auto);
      rowDef3.Height = new GridLength(1, GridUnitType.Star);
      rowDef4.Height = new GridLength(1, GridUnitType.Auto);
      rowDef5.Height = new GridLength(1, GridUnitType.Auto);
      rowDef6.Height = new GridLength(1, GridUnitType.Auto);
      rowDef7.Height = new GridLength(1, GridUnitType.Auto);
      _host.RowDefinitions.Add(rowDef1);
      _host.RowDefinitions.Add(rowDef2);
      _host.RowDefinitions.Add(rowDef3);
      _host.RowDefinitions.Add(rowDef4);
      _host.RowDefinitions.Add(rowDef5);
      _host.RowDefinitions.Add(rowDef6);
      _host.RowDefinitions.Add(rowDef7);

      _xSlider = new Slider() {
        Margin = new Thickness(-5, 0, -5, 0),
        IsHitTestVisible = true,
        Visibility = System.Windows.Visibility.Collapsed
      };

      Grid.SetColumn(_xSlider, 2);
      Grid.SetRow(_xSlider, 5);
      _host.Children.Add(_xSlider);

      _titleBox = new TextBlock()
      {
          Margin = new Thickness(0),
          Text = "Title",
          HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
          VerticalAlignment = System.Windows.VerticalAlignment.Stretch,
          TextAlignment = TextAlignment.Center,
          //Background = radialBrush,
          IsHitTestVisible = false,
          Visibility = Visibility.Collapsed
      };
      Grid.SetColumn(_titleBox, 2);
      Grid.SetRow(_titleBox, 0);
      _host.Children.Add(_titleBox);

      _legendBox = new UniformWrapPanel() {
        Margin = new Thickness(5),
        //Background = new SolidColorBrush(Color.FromArgb(0x2F, 0, 0, 0)),
        IsHitTestVisible = false
      };
      Grid.SetColumn(_legendBox, 0);
      Grid.SetRow(_legendBox, 1);
      Grid.SetColumnSpan(_legendBox, 3);
      _host.Children.Add(_legendBox);

      _xTitleBar = new Rectangle() {
        Margin = new Thickness(0),
        //Fill = radialBrush,
        IsHitTestVisible = false
      };
      Grid.SetColumn(_xTitleBar, 0);
      Grid.SetRow(_xTitleBar, 4);
      Grid.SetColumnSpan(_xTitleBar, 3);
      _host.Children.Add(_xTitleBar);

      _yTitleBar = new Rectangle() {
        Margin = new Thickness(0),
        //Fill = radialBrush,
        IsHitTestVisible = false
      };
      Grid.SetColumn(_yTitleBar, 0);
      Grid.SetRow(_yTitleBar, 2);
      Grid.SetRowSpan(_yTitleBar, 3);
      _host.Children.Add(_yTitleBar);

      _xGridLineLabels = new Rectangle() {
        Margin = new Thickness(2, 0, 0, 2),
        Fill = Brushes.Transparent, // new SolidColorBrush(Color.FromArgb(127, 255, 255, 255)),
        IsHitTestVisible = false
      };
      Grid.SetColumn(_xGridLineLabels, 1);
      Grid.SetRow(_xGridLineLabels, 3);
      Grid.SetColumnSpan(_xGridLineLabels, 2);
      _host.Children.Add(_xGridLineLabels);

      _yGridLineLabels = new Rectangle() {
        Margin = new Thickness(2, 0, 0, 2),
        Fill = Brushes.Transparent, //new SolidColorBrush(Color.FromArgb(127, 255, 255, 255)),
        IsHitTestVisible = false
      };
      Grid.SetColumn(_yGridLineLabels, 1);
      Grid.SetRow(_yGridLineLabels, 2);
      Grid.SetRowSpan(_yGridLineLabels, 2);
      _host.Children.Add(_yGridLineLabels);


        var gridLineBorder = new Border()
        {
            Margin = new Thickness(3),
            BorderThickness = new Thickness(1),
            BorderBrush = Brushes.LightGray,
            IsHitTestVisible = false
        };

      _gridLineCanvas = new GridLineCanvas() {
        Margin = new Thickness(0),
        IsHitTestVisible = false
      };
        gridLineBorder.Child = _gridLineCanvas;
      Grid.SetColumn(gridLineBorder, 2);
      Grid.SetRow(gridLineBorder, 2);
      _host.Children.Add(gridLineBorder);

      _imageHost = new Image() {
        Margin = new Thickness(0),
        Stretch = Stretch.None,
        RenderTransformOrigin = new Point(0.5, 0.5),
        RenderTransform = invertTransform,
        HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
        VerticalAlignment = System.Windows.VerticalAlignment.Top,
        IsHitTestVisible = false
      };
      Grid.SetColumn(_imageHost, 2);
      Grid.SetRow(_imageHost, 2);
      _host.Children.Add(_imageHost);

      _cursorCoordinateCanvas = new CursorCoordinateCanvas() {
        Margin = new Thickness(0),
        RenderTransformOrigin = new Point(0.5, 0.5),
        RenderTransform = invertTransform,
        ClipToBounds = false,
        Background = new SolidColorBrush(Colors.Transparent),
        IsHitTestVisible = false
      };
      Grid.SetColumn(_cursorCoordinateCanvas, 2);
      Grid.SetRow(_cursorCoordinateCanvas, 2);
     // _host.Children.Add(_cursorCoordinateCanvas);

      _subNotes = new ListView() {
        FontSize = 10,
        Visibility = System.Windows.Visibility.Collapsed,
        Background = new SolidColorBrush(Colors.Transparent),
        BorderBrush = new SolidColorBrush(Colors.Transparent),
      };

      Border subNotesBorder = new Border() {
        Background = new SolidColorBrush(Color.FromArgb(0x20, 0, 0, 0)),
        BorderBrush = new SolidColorBrush(Colors.Transparent),
        BorderThickness = new Thickness(0),
        Padding = new Thickness(0),
        CornerRadius = new CornerRadius(8),
        IsHitTestVisible = false
      };
      Grid.SetColumn(subNotesBorder, 0);
      Grid.SetRow(subNotesBorder, 6);
      Grid.SetColumnSpan(subNotesBorder, 3);
      subNotesBorder.Child = _subNotes;
      _host.Children.Add(subNotesBorder);

      DockPanel.SetDock(_host, Dock.Left);
      this.Children.Add(_host);

    }