Xaml binding isnt working....

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

VadimTr wrote at 2013-10-21 22:49:

Hi,
When i create graph in XAML, then binding to observable collection - it isn't working.
Why?
        <oxy:Plot Margin="10">
            <oxy:LineSeries x:Name="OxyPlotLine"
                            Width="Auto"
                            Height="Auto" ItemsSource="{Binding Mode=OneWay, Source={StaticResource ChartPoints}}" />
        </oxy:Plot>
            for (double i = 0; i <= stopValue; i++)
            {
                ii =+ i;
                CPColl.Add(new ChartPoint(i, CPColl.Count););             
            }
    class ChartPoint
    {
        private double _X;
        private double _Y;

        public ChartPoint(double X, double Y)
        {
            _X = X;
            _Y = Y;
        }

        public double X
        { get { return _X; } set { _X = value; } }

        public double Y
        { get { return _Y; } set { _Y = value; } }
    }
    class ChartPointsCollection: ObservableCollection<ChartPoint>
    {
        public ChartPointsCollection() : base()
        {  }
    }

objo wrote at 2013-10-22 22:55:

OxyPlot is not automatically refreshing the plot when the collection changes (this was a design choice and I know it is different from normal WPF control behaviour). You need to trig the Invalidate or Refresh method on the Plot control yourself. I'll consider again if the OxyPlot.Wpf.ItemsSeries should listen to collection changes (and item property changes...)

VadimTr wrote at 2013-10-22 23:14:

Thank your for answer

Can your write a sample?

VadimTr wrote at 2013-10-22 23:21:

Can i use observable collections?

objo wrote at 2013-10-23 07:59:

Yes, you can use any collection. See the examples in Source\Examples\Wpf