Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
Custom Label
posted

Hi;

Can we do custom label in WPF? I create one in win form, but don't sure if you provide this function in WPF.

thanks ...

 

/Cathy

Parents
  • 739
    posted

    This is the way how to create a custom drawing:

    1.       Create a canvas and add the XamChart to it as a child.

    2.       Use mouse event and add a TextBlock to the canvas as a child.

    3.       Use GetPosition methods to get pixel position from axis values.

     

    Thanks,

    GoranS

     

    See sample below

    XAML:

    <Grid x:Name="LayoutRoot">
       <Canvas Name="Canvas1" Margin="0,0,0,0">
          <igCA:XamChart Name="Chart1" Width="523" Height="329"/>
       </Canvas>
    </Grid>

    C#:

    protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e)
            {
                double x1 = Chart1.GetPosition(Infragistics.Windows.Chart.AxisType.PrimaryX, 1);
                double y1 = Chart1.GetPosition(Infragistics.Windows.Chart.AxisType.PrimaryY, 10);
                Canvas canvas = Chart1.Scene.GridArea.Content as Canvas;

                TextBlock text = new TextBlock();
                text.Foreground = Brushes.Red;
                text.Text = "Test";
                Canvas.SetLeft(text, x1);
                Canvas.SetTop(text, y1);

                Canvas1.Children.Add(text);

                base.OnMouseDown(e);
            }

Reply Children
No Data