0

I'm tryig to use TabControl in Caliburn micro WPF project. I have two ViewModels (userControls) and I want the user to switch between them using tabcontrol.

I tried two different approaches, but I get the same problem with both of them. After switching tabs (I click on second tab and then back on first), my application starts visibly lagging. For example if I click on a checkbox there is a visible delay.

It is the same problem as in this question: TabControl becoming very laggy, difference is that I am using caliburn micro and I am not sure that ListBox would be appropriate in my situation.

I tried implementing it this way:

  <TabControl>
      <TabItem Header="Item1">
            <ContentControl
                    x:Name="Item1"/>
            </TabItem>
            <TabItem Header="Item2">
                <ContentControl
                    x:Name="Item2"/>
            </TabItem>
        </TabControl>

I also tried using Conductor.Collection.OneActive:

this.Items.Add(Item1);
this.Items.Add(Item2);

XAML:

<TabControl Name="Items"/>

Everything works fine, it loads fast, tab switching is fast. The only problem is that rendering performance is really bad.

Any help would be appreciated.

d7vid
  • 19
  • 4
  • What goes in your tabitems? How's it and any viewmodel instantiated - what's in there that could take time? – Andy Dec 18 '19 at 15:03
  • @Andy: I actually commented everything out, so now the second tab is completely empty. The lag is a bit better, but still quite noticable. In the first tab I have a chart made by LiveChart library. When panning and zooming the lag is most noticable. But only after switching tabs. I do it like this: `Item1= new Item1ViewModel(events);` `Item2= new Item2ViewModel(events);` `this.Items.Add(Item1);` `this.Items.Add(Item2);` – d7vid Dec 19 '19 at 06:46
  • is it possible to have the complete project on github for example, because its impossible to understant the problem with these few lines of code...? – Frenchy Dec 23 '19 at 10:38
  • how are the viewmodels loaded for the tabs? are you using DI and what is the lifetime of each viewmodel? – mvermef Dec 26 '19 at 06:03

0 Answers0