Error: This PlotModel is already in use by some other PlotView control
Asked Answered
I

2

5

I have two tabs that is bind to one viewmodel which contain a PlotModel of oxyplot and view model selected through a DataTemplate. When click on the first tab the viewmodel was bind properly but when switch to second tab above exception defined in title throw. All of control is same in two tab. Is it possible bind one object to two controls?

Intercommunion answered 14/9, 2014 at 13:0 Comment(1)
Post relevant code here. It's difficult to answer without seeing your code.Slaphappy
A
8

I know what problem you are facing, as I had faced it myself. Oxyplot does not let you bind one model to two plots.

The reason: Once you assign a PlotModel to a Plotview, it becomes encapsulated in that PlotView object.

The only way you can solve the problem is to create separate PlotModel for each PlotView.

Arneson answered 11/10, 2014 at 18:59 Comment(0)
G
0

If I understood you correctly. When switching from a Page, you should reset the oxymodel. I'll show you by my example.

 <StackPanel >
     <StackPanel Orientation="Horizontal">
         <AppBarButton Label="Выбрать время" Icon="Calendar" Click="AppBarButton_Click"  ></AppBarButton>
         <AppBarButton Label="Последнее измерение" Icon="BackToWindow" Click="AppBarButton_Click_1"></AppBarButton>
     </StackPanel>
     <oxy:PlotView Name="oxyPlotComponent" Height="600" Width="700" 
                   Model="{x:Bind ViewModel.PlotFilling, Mode=OneWay}"
                   CacheMode="BitmapCache"/>
 </StackPanel>

When leaving the page, clear the oxyplot.

 private void Page_Unloaded(object sender, RoutedEventArgs e)
 {
     oxyPlotComponent.Model = null;
 }
Gnni answered 11/10, 2024 at 6:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.