Using DataVisualization Chart library shows "ghosts" points WPF MVVM C# -


i have program wrote in wpf mvvm , have view using datavisualization chart library (dvc.dll) shows graphs on view.

in viewmodel have several observablecollections<> contains datapoints reflects on graph right , after several minutes of use graph starts shows "ghosts" points of previous charts , won't refreshed until restart whole program.

i try use clear() function each collection before updates new points, , added small thread.sleep() delays when changing data in collections, nothing helps.

any solutions?

enter image description here

view:

<dvc:chart title="cross section" background="lightsteelblue" height="385" >     <dvc:chart.series>         <!--ground line-->         <dvc:lineseries isselectionenabled="true" independentvaluebinding="{binding path=x}"                          selecteditem="{binding selectedpointongraph, mode=twoway}"                          dependentvaluebinding="{binding path=y}" itemssource="{binding hydropoints, bindsdirectlytosource=true, mode=twoway, updatesourcetrigger=propertychanged}"                          transitionduration="0">             <dvc:lineseries.datapointstyle>                 <style targettype="{x:type dvc:linedatapoint}">                     <setter property="background" value="saddlebrown" ></setter>                     <setter property="opacity" value="2" />                     <setter property="tooltip" value="{binding path=coordinate}" />                     <setter property="template" >                         <setter.value>                             <controltemplate targettype="dvc:linedatapoint">                                 <grid>                                     <ellipse fill="{templatebinding background}" />                                     <canvas>                                         <textblock fontweight="bold"                                                     text="{binding path=pointnote, mode=oneway, updatesourcetrigger=propertychanged}"/>                                     </canvas>                                 </grid>                             </controltemplate>                         </setter.value>                     </setter>                 </style>             </dvc:lineseries.datapointstyle>             <dvc:lineseries.template>                 <controltemplate targettype="dvc:lineseries">                     <canvas x:name="plotarea">                         <polyline x:name="polylinee"                           points="{templatebinding points}"                            stroke="saddlebrown"                            style="{templatebinding polylinestyle}" />                     </canvas>                 </controltemplate>             </dvc:lineseries.template>         </dvc:lineseries>     </dvc:chart.series> </dvc:chart> 

hydropoints.cs (the model file has same properties set\get onpropertychanged event)

public class hydropoint : businessobjectbase {     public int pointid { get; set; }     public int stationid { get; set; }     public int sectionid { get; set; }     public datetime sectionmesurdate { get; set; }     public single x { get; set; }     public single y { get; set; }     public string pointnote { get; set; }     public single pointroughnesscoefficient { get; set; } } 

hydromainviewmodel.cs

    public observablecollection<hydropoint> hydropoints     {         { return _hydropoints.orderby(x => x.x).toobservablecollection(); }         set         {             if (_hydropoints == value)                 return;             _hydropoints= value;             onpropertychanged("hydropoints");         }     }       public void setselectedsectionbyconbobox()     {         if (rpointslist != null && rpointslist.count >= 0)             rpointslist.clear();         if (hydropoints != null && hydropoints.count >= 0)             hydropoints.clear();                          [....]         hydropoints = repository.hydropointsrepository.hydropoints.where(x => x.stationid == currentstation.serialcode && x.sectionid == selectedsectionid && x.sectionmesurdate == _selectedmesurdate).toobservablecollection<hydropoint>();        rpointslist = repository.hydropointsrepository.rpoints().where(x => x.stationid == currentstation.serialcode && x.sectionid == selectedsectionid && x.sectionmesurdate == selectedsectionmesurdate).toobservablecollection<hydropoint>();           [....]     } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -