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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:53:51+00:00 2026-05-29T03:53:51+00:00

I am trying to bind an ObservableCollection of data from my ViewModel to the

  • 0

I am trying to bind an ObservableCollection of data from my ViewModel to the Devexpress 2D Stock Chart in the View. I know that the VM is bound do the View’s DataContext because I have the window’s Title bound to a property in the VM and it is correct when I run the program. The collection is instantiated correctly, I can see that all the objects are created, have values, and are added to the collection.

The chart information just isn’t displaying. The chart shows up just not the information that is supposed to be bound to it. I’m guessing it has to do with a line in my XAML but I just don’t know what it is.

Here is the Error from the Output:

System.Windows.Data Error: 40 : BindingExpression path error:
‘Snapshots’ property not found on ‘object’ ”ChartElementPanel’
(Name=”)’. BindingExpression:Path=DataContext.Snapshots;
DataItem=’ChartElementPanel’ (Name=”); target element is
‘StockSeries2D’ (HashCode=24500892); target property is ‘DataSource’
(type ‘Object’)

The DevExpress version is 10.1.9

EDIT:
I think I know where the problem is coming in at. The StockSeries2D DataContext = DevExpress.Xpf.Charts.ChartElementPanel So when I use

DataSource="{Binding Path=DataContext.Snapshots}"

It really points to the DevExpress.Xpf.Charts.ChartElementPanel and since it doesn’t contain a Snapshots property the error is thrown.

XAML:

    <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="200" />
        <RowDefinition Height="50" />
    </Grid.RowDefinitions>
    <dxc:ChartControl Name="chartControl1">
        <dxc:ChartControl.Diagram>
            <dxc:XYDiagram2D>
                <dxc:XYDiagram2D.Series>
                    <dxc:StockSeries2D DataSource="{Binding DataContext.Snapshots}" HighValueDataMember="High" LowValueDataMember="Low" CloseValueDataMember="Last" ArgumentScaleType="DateTime" ArgumentDataMember="TimeStamp">

                        <dxc:StockSeries2D.PointOptions>
                            <dxc:PointOptions dxc:FinancialSeries2D.ValueToDisplay="HighValue" />
                        </dxc:StockSeries2D.PointOptions>

                        <dxc:StockSeries2D.Model>
                            <dxc:ArrowsStock2DModel />
                        </dxc:StockSeries2D.Model>
                    </dxc:StockSeries2D>
                </dxc:XYDiagram2D.Series>

                <!--Region #Axis X-->
                <dxc:XYDiagram2D.AxisX>
                    <dxc:AxisX2D>
                        <dxc:AxisX2D.DateTimeOptions>
                            <dxc:DateTimeOptions Format="ShortTime" />
                        </dxc:AxisX2D.DateTimeOptions>
                    </dxc:AxisX2D>
                </dxc:XYDiagram2D.AxisX>
                <!-- End Rgion -->

                <!-- region #AxisY -->
                <dxc:XYDiagram2D.AxisY>
                    <dxc:AxisY2D>
                        <dxc:AxisY2D.Range>
                            <dxc:AxisRange dxc:AxisY2D.AlwaysShowZeroLevel="False" />
                        </dxc:AxisY2D.Range>
                    </dxc:AxisY2D>
                </dxc:XYDiagram2D.AxisY>

                <!--End Rgion-->
            </dxc:XYDiagram2D>
        </dxc:ChartControl.Diagram>
    </dxc:ChartControl>
</Grid>

ViewModel:

    public class MainWindowViewModel : INotifyPropertyChanged
{
    ObservableCollection<ISnapShot> _snapShots;
    string _windowTitle;

    public MainWindowViewModel()
    {
        _snapShots = new ObservableCollection<ISnapShot>();
        LoadSnapshots();
        WindowTitle = Snapshots.First().Symbol;
    }

    public ObservableCollection<ISnapShot> Snapshots
    {
        get { return _snapShots; }
    }

    public String WindowTitle
    {
        get { return _windowTitle; }
        set { _windowTitle = value; OnPropertyChanged("WindowTitle"); }
    }

    private void AddSnapshot(ISnapShot snapshot)
    {
        _snapShots.Add(snapshot);
    }

    private void LoadSnapshots()
    {
        int counter = 0;

        while (counter < 5)
        {
            ISnapShot s = new Snapshot()
            {
                TimeStamp = DateTime.Now,
                Symbol = "XYZ",
                High = (counter + 1) * 5,
                Low = (counter + 1) * 2,
                Last = (counter + 1) * 3
            };

            _snapShots.Add(s);
            counter++;
            Thread.Sleep(1000);
        }

    }

    public event PropertyChangedEventHandler PropertyChanged;
    void OnPropertyChanged(string prop)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(prop));
    }
}

View:

    public partial class MainWindow : Window
{
    private MainWindowViewModel _vm;


    public MainWindow(MainWindowViewModel vm)
    {
        InitializeComponent();
        _vm = vm;
        this.DataContext = _vm;
    }
}

App:

public partial class App : Application
{
    private void OnStartup(object sender, StartupEventArgs e)
    {
        MainWindowViewModel vm = new MainWindowViewModel();
        Views.MainWindow view = new Views.MainWindow(vm); 
        view.Show();
    }
}
  • 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-29T03:53:51+00:00Added an answer on May 29, 2026 at 3:53 am

    I figured it out. Since the DataContext of StockSeries2D does not point to the DataContext of the Window

    <dxc:StockSeries2D DataContext="DevExpress.Xpf.Charts.ChartElementPanel"

    I needed to set the DataSource to use the Window’s DataContext

    <dxc:StockSeries2D DataSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Snapshots}"

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

Sidebar

Related Questions

I'm trying to bind a combobox to a ObservableCollection.When the form is displayed the
I am trying to successfully TwoWay bind an ObservableCollection to TextBoxes in a DataTemplate.
I'm trying to bind a list of data to a data grid, but can't
I am trying to bind a model coming from the server over json to
Hi I'm trying to bind data to a kendochart, but no bars are appearing
I have read that SL4 introduces the ability to data bind properties on objects
I'm trying to bind an ObservableCollection to a treeview in WPF. It does kind-of
I am trying to bind a property ObservableCollection<ObservableCollection<Location>> to a ListBox with ItemTemplate of
I'm trying to bind a combobox to a list of items (ObservableCollection) on my
I have a ListBox data bound to an ObservableCollection<Employee> . It is working well.

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.