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 1011935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:52:05+00:00 2026-05-16T09:52:05+00:00

I am trying to add Series binding to the Visifire graphing controls set. To

  • 0

I am trying to add Series binding to the Visifire graphing controls set. To this end i have created a SeriesSource dependency property of time DataSeriesCollection. This is bound in the front end using:

`<Chart SeriesSource={Binding Series} />`  

Problem
When the source changes, the validation callback is called. The value that is passed to this is the correct value, a populated ObservableCollection<something>. Immediately after the validate value is called, the CoerceValue callback is called by something, and the value that is sent to it is an EMPTY ObservableCollection<something>. Bounty will go to anyone who can:

  1. Get the correct populated ObservableCollection<someting> passed to the CoerceValue callback OR
  2. Get the correct value being passed to the OnSeriesSourceChanged callback OR
  3. Explain to me how i can do any of the above 🙂

Here is the data template for the view:

<DataTemplate DataType="{x:Type vm:ReportViewModel}">
    <Grid Name="rootGrid">
    <visifire:Chart Grid.Row="1" SeriesSource="{Binding Series}">
        <visifire:Chart.AxesX>
                <visifire:Axis Title="X axis" />
        </visifire:Chart.AxesX>
        <visifire:Chart.AxesY>
                <visifire:Axis Title="Y axis" />
        </visifire:Chart.AxesY>
    </visifire:Chart>
    </Grid>
</DataTemplate>

Here is the target Dependency Property

    //Getter and setter for Dependency Property
    public ObservableCollection<DataSeries> SeriesSource
    {
        get { return (ObservableCollection<DataSeries>)GetValue(SeriesSourceProperty); }
        set { SetValue(SeriesSourceProperty, value);           }
    }

    // Using a DependencyProperty as the backing store for SeriesSource.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty SeriesSourceProperty =
        DependencyProperty.Register("SeriesSource", typeof(ObservableCollection<DataSeries>), typeof(Chart), new UIPropertyMetadata(new ObservableCollection<DataSeries>(), new PropertyChangedCallback(OnSeriesSourceChange), new CoerceValueCallback(CoerceSeries)), new ValidateValueCallback(ValidateSeriesSource));

    //Value validation callback
    private static bool ValidateSeriesSource(object value)
    {
        if (value as ObservableCollection<DataSeries> != null)
            return true;
        return false;
    }

    //Dependency Property Changed callback
    private static void OnSeriesSourceChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        Chart c = d as Chart;
        if (c == null)
            return;
        //This line was causing the issue. It was overriding the setter
        c.SeriesSource = (DataSeriesCollection)e.NewValue;
    }

    //Coerce Value callback
    private static object CoerceSeries(DependencyObject d, object value)
    {
        Chart c = d as Chart;
        var collection = value as System.Collections.ObjectModel.ObservableCollection<Visifire.Charts.DataSeries>;
        foreach (var item in c.Series)
        {
            if (!collection.Contains(item))
                c.Series.Remove(item);
        }
        foreach (var item in collection)
        {
            if (!c.Series.Contains(item))
                c.Series.Add(item);
        }
        return collection;
    }

New information
The value being received by the CoerceValue callback is ALWAYS the first value which that property was set to. So if the first value i pass it is a list with 1 item, it will always coerce the value back to a list with one item!

Edit: found the issue, it was in the property changed callback. Credit goes to Matt for helping me out with the CoerceValue callback

  • 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-16T09:52:06+00:00Added an answer on May 16, 2026 at 9:52 am

    This may not be the exact problem, but you have logic in your setter. That code isn’t going to be executed when the property is assigned via a binding.

    Instead of adding logic to your setter, consider using a “coerced” callback which gets called every time a value is assigned to your property. See here for more details about “coerce value” callbacks. They’re very similar to what you’ve done for your “property changed” callback.

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

Sidebar

Related Questions

I have been trying to add click events to a series of divs using
I'm trying to programmatically add a series to a Dundas TreeMap but I'm getting
This is a question about the best way to add up a series of
I'm trying to add many series to a chart using VBA, as in the
I have a json object which I am trying to add to my highcharts
I have an auth plugin working. I am trying to add ACL to it
I'm trying to add a series (composed of a list of [1,2,0,....]) to a
I am trying to add a series of numbers to a string, but not
i have big problem with binding Stacked Column Series to my chart. I have
I am trying to programmatically add a column series to a wpf toolkit chart.

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.