Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:53:12+00:00 2026-06-12T23:53:12+00:00

I have this silverlight line chart and I would like to implement zooming and

  • 0

I have this silverlight line chart and I would like to implement zooming and pan, since it is difficult to analyze the data in this view (Datapoints are hidden because they make the chart look like a mess, but I would like to enable it again in a certain level of zoom).

Any ideas/examples?

My chartwindow.xaml:

     <controls:ChildWindow x:Class="HuginOdinSilverlight.Views.UserStats.chartwindow"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:DV="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:DVC="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
       xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" Title="Advanced LineChart" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="422" d:DesignWidth="1029">
<controls:ChildWindow.Resources>
    <Style x:Key="LegendItemStyle" TargetType="DVC:LegendItem">
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DVC:LegendItem">
                    <CheckBox Click="CheckBox_Click" Cursor="Hand" IsChecked="true" Content="{TemplateBinding Content}" Tag="{TemplateBinding Content}">
                        <CheckBox.Template>
                            <ControlTemplate TargetType="CheckBox">
                                <StackPanel Orientation="Horizontal">
                                    <Rectangle Width="8" Height="8" Fill="{Binding Background}" Stroke="{Binding BorderBrush}"
                                               StrokeThickness="1" Margin="0,0,3,0" />
                                    <DV:Title Content="{TemplateBinding Content}"/>
                                </StackPanel>
                            </ControlTemplate>
                        </CheckBox.Template>
                    </CheckBox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</controls:ChildWindow.Resources>
<Grid x:Name="LayoutRoot" Margin="2" Height="385" Width="1007">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />

    </Grid.RowDefinitions>
    <DVC:Chart x:Name="userChart2" BorderBrush="{x:Null}" Visibility="Visible" Padding="20,10,20,20" Margin="0,0,0,0">
        <DVC:AreaSeries Name="lseries" IndependentValueBinding="{Binding Path=label}" DependentValueBinding="{Binding Path=number}" />


    </DVC:Chart>

        <CheckBox Content="affectedDocs" Height="21" HorizontalAlignment="Left" Margin="900,352,0,0" Name="checkBox1" VerticalAlignment="Top" Width="95" Checked="checkBox1_Checked" Unchecked="checkBox1_Unchecked" />
</Grid>

My chartwindow.xaml.cs:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using HuginOdinSilverlight.ServiceReference1;
    using System.Windows.Data;
    using System.Windows.Controls.DataVisualization;
    using System.Windows.Controls.DataVisualization.Charting;

    namespace HuginOdinSilverlight.Views.UserStats
    {
        public partial class chartwindow : ChildWindow
        {
            List<List<Service2ef_chart>> thelist;
    List<object> names = new List<object>();
    public chartwindow(List<List<Service2ef_chart>> list, List<object> comboitems)
    {
        InitializeComponent();
        thelist = list;
        names = comboitems;
        refreshChart();

    }

    private void checkBox1_Checked(object sender, RoutedEventArgs e)
    {
        refreshChart();
    }

    void refreshChart()
    {
        int i = 0;
        int palindex = 0;
        userChart2.Series.Clear();

        foreach (List<Service2ef_chart> each in thelist)
        {
            Style newStyle = new Style(typeof(LineDataPoint));
            newStyle.Setters.Add(new Setter(LineDataPoint.BackgroundProperty, userChart2.Palette[palindex]["Background"]));
            newStyle.Setters.Add(new Setter(LineDataPoint.HeightProperty, 0));
            newStyle.Setters.Add(new Setter(LineDataPoint.WidthProperty, 0));

            userChart2.Series.Add(new LineSeries
            {
                ItemsSource = each,
                IndependentValueBinding = new Binding("label"),
                DependentValueBinding = (bool)checkBox1.IsChecked ? new Binding("number2") : new Binding("number"),
                Title = names[i].ToString(),
                LegendItemStyle = (Style)Resources["LegendItemStyle"],
                DataPointStyle = newStyle
            });

            i++;
            ++palindex;

            if (palindex >= userChart2.Palette.Count)
            {
                palindex = 0;
            }
        }
    }

    private void checkBox1_Unchecked(object sender, RoutedEventArgs e)
    {
        refreshChart();
    }



     //adds or removes series from the linechart when clicking on the legend:
    private void CheckBox_Click(object sender, RoutedEventArgs e)
    {
        CheckBox chk = (sender as CheckBox);
        Series ser = userChart2.Series.Cast<Series>().Where(s => s.Title.ToString() == chk.Tag.ToString()).ElementAtOrDefault(0);
        if (chk.IsChecked.Value)
        {
            chk.Opacity = 1;
            ser.Visibility = Visibility.Visible;
            try { ((LineSeries)ser).ItemsSource = thelist[names.IndexOf(chk.Tag.ToString())]; }
            catch (Exception yy) { MessageBox.Show(yy.Message); }
        }
        else
        {
            chk.Opacity = 0.25;
            ser.Visibility = Visibility.Collapsed;
            ((LineSeries)ser).ItemsSource = null;
        }
    }


}

}

Btw, ideas to make the code nicer are strongly appreciated 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:53:12+00:00Added an answer on June 12, 2026 at 11:53 pm

    Plesae go through the following links to implement zoom and pan in silver light chart.

    Zoom and pan for silver light chart

    Zoom and pan for silver light

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a line series chart called lineSeries1. I would like that chart to
Hy, I have a chart,wich is created in runtime,this could be Line, Bar or
What are my options for printing in Silverlight 3? Assume I have this awesome
The CollectionViewSource.GetDefaultView() method is not in Silverlight 3. In WPF I have this extension
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
i have a class 'MyTextBox' that derives from the default TextBox in Silverlight. This
Ok, so this question probably isn't Silverlight specific. I have a silverlight 2 page
I have this application where I implement the ActionBar Fragment interface. Underlying the interface,
I have an MVC application which uses a silverlight control. Somewhere along the line
I have this method that logs errors from the Silverlight client: [MethodImpl(MethodImplOptions.NoInlining)] public static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.