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

  • Home
  • SEARCH
  • 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 6705809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:26:49+00:00 2026-05-26T07:26:49+00:00

I’m developing a Silverlight Project which involves Chart Controls. I’m using Chart Control &

  • 0

I’m developing a Silverlight Project which involves Chart Controls.

I’m using Chart Control & on its series I’ve implemented Left Click Context Menu which has two MenuItems viz. “Expand” & “Drill”.

public class WebChart : Chart
{
     ContextMenu ChartItemDataMenu;

     public WebChart()
        : base()
    {
        this.Loaded += new RoutedEventHandler(WebChart_Loaded);
    }

    private void WebChart_Loaded(object sender, RoutedEventArgs e)
    {
        MenuItem expand = new MenuItem();
        expand.Click += new RoutedEventHandler(OnExpand_Click);
        ToolTipService.SetToolTip(expand, "Expand");

        MenuItem drill = new MenuItem();
        drill.Click += new RoutedEventHandler(OnDrill_Click);
        ToolTipService.SetToolTip(drill, "Drill");

        ChartItemDataMenu = new ContextMenu();

        ChartItemDataMenu.Items.Add(expand);
        ChartItemDataMenu.Items.Add(drill);

        this.DataItemMouseLeftButtonDown += 
            new EventHandler<DataItemMouseEventArgs>(ExtendedXamWebChart_DataItemMouseLeftButtonDown);

        this.MouseRightButtonDown -= (s, eventArgs) => { eventArgs.Handled = true; };
        this.MouseRightButtonDown += (s, eventArgs) => { eventArgs.Handled = true; };
    }

    private void ExtendedXamWebChart_DataItemMouseLeftButtonDown(object sender, DataItemMouseEventArgs e)
    { 
        ChartItemDataMenu.IsOpen = true;
    }

For both the Menu Items I’ve declared seperate click events, registered them and raised them.
Then I’ve bonded these events in XAML to ICommand Properties in the View Model.

    public delegate void WebChartEventHandler(object sender, DataItemMouseEventArgs e, DataPoint dp, qcPoint qp);

    public event WebChartEventHandler ExpandClickEvent;
    public event WebChartEventHandler DrillClickEvent;

    private void OnDrill_Click(object sender, RoutedEventArgs e)
    {
        if (currentDataItemMouseEventArgs == null)
            currentDataItemMouseEventArgs = new DataItemMouseEventArgs();
        if (DrillClickEvent != null)
        { DrillClickEvent(sender, currentDataItemMouseEventArgs, SelectedDataPoint, CurrentSelectedPoint); }
    }

    private void OnExpand_Click(object sender, RoutedEventArgs e)
    {
        if (currentDataItemMouseEventArgs == null)
            currentDataItemMouseEventArgs = new DataItemMouseEventArgs();
        if (ExpandClickEvent != null)
        { ExpandClickEvent(sender, currentDataItemMouseEventArgs, SelectedDataPoint, CurrentSelectedPoint); }
    }
}

But on Debugging the Code, I get “ExpandClickEvent” & “DrillClickEvent” as null as there is no one listening to it.

I’m using this WebChart Control in another User Control named ChartBaseControl which in turn is used in another User Control named Graph Control.
DataContext is properly getting setup.
I’ve created a ViewModel named ViewModelGraphControl.

I believe there is something I’m missing.
Please look after the issue.

Edited Content: XAML:

<extnchart:WebChart Grid.Row="0" x:Name="CTRLWebChart" VerticalAlignment="Stretch" 
                                           Margin="0,-23,0,0" IsDrillEnable="True" 
                                           local:AxisTitleSettings.XAxisTitle="X-Axis" 
                                           local:AxisTitleSettings.YAxisTitle="Y-Axis" 
ChartSeriesCollection="{Binding WebChartSource, Mode=TwoWay}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="DrillClickEvent">
                        <command:EventToCommand Command="{Binding OnDrill_Click}"     PassEventArgsToCommand="True"/>
                    </i:EventTrigger>
                    <i:EventTrigger EventName="ExpandClickEvent">
                        <command:EventToCommand Command="{Binding OnExpand_Click}"     PassEventArgsToCommand="True"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <extnchart:ExtendedXamWebChart.Axes>
                    <igWebChart:Axis AxisType="PrimaryX">
                        <igWebChart:Axis.Label>
                            <igWebChart:LabelGroup DistanceFromAxis="2"/>
                        </igWebChart:Axis.Label>
                    </igWebChart:Axis>
                    <igWebChart:Axis AxisType="PrimaryY">
                        <igWebChart:Axis.Label>
                            <igWebChart:LabelGroup FontSize="11"/>
                        </igWebChart:Axis.Label>
                    </igWebChart:Axis>
                </extnchart:ExtendedXamWebChart.Axes>
            </extnchart:ExtendedXamWebChart>
  • 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-05-26T07:26:50+00:00Added an answer on May 26, 2026 at 7:26 am

    I found the answer to the query.

    Instead of using custom Event Handlers, I used Routed Event Handlers as the event is routed between pages.

    And in order to send my custom parameters to the ViewModel, I created a new Class named ExtendedRoutedEventArgs and inherited it from RoutedEventArgs class and created fields & properties that I wanted to access.

        public class ExtendedRoutedEventArgs : RoutedEventArgs
        {
            public ExtendedRoutedEventArgs()
                : base()
            {
    
            }
            private DataItemMouseEventArgs currentDataItemMouseEventArgs;
    
            public DataItemMouseEventArgs CurrentDataItemMouseEventArgs
            {
                get { return currentDataItemMouseEventArgs; }
                set { currentDataItemMouseEventArgs = value; }
            }
    
            private DataPoint selectedDataPointe;
    
            public DataPoint SelectedDataPointe
            {
                get { return selectedDataPointe; }
                set { selectedDataPointe = value; }
            }
    
            private qcPoint currentSelectedQcPoint;
    
            public qcPoint CurrentSelectedQcPoint
            {
                get { return currentSelectedQcPoint; }
                set { currentSelectedQcPoint = value; }
            }
        }
    

    Next, I raise my Event in the Following Manner:

    public class WebChart : Chart
    {
        void OnDrill_Click(object sender, RoutedEventArgs e)
        {
            if (currentDataItemMouseEventArgs == null)
    
                currentDataItemMouseEventArgs = new DataItemMouseEventArgs();
            if (DrillClickEvent != null)
            {
                DrillClickEvent(sender, new ExtendedRoutedEventArgs
                {
                    CurrentDataItemMouseEventArgs = currentDataItemMouseEventArgs,
                    SelectedDataPointe = SelectedDataPointe,
                    CurrentSelectedQcPoint = CurrentSelectedQcPoint
                });
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from

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.