Search code examples
wpflivecharts

It's not scrollable vertically in case of LiveCharts in WrapPanel of WPF,


I implemented the presentation of several charts by the LiveChart in ListBox. It works well. It's displayed by wrapping charts on page space automatically. But, It's not scrollable vertically.

It's scrollable horizontaly when I set ScrollViewer.HorizontalScrollBarVisibility as Enabled as 1 line with a horizontal scrollbar.

But, It is not the result what i want by using the wrapPanel.

Do you have this kind of experience? Please help me.

<StackPanel Orientation="Vertical">
<ListBox ItemSource="{Binding info}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
  <ListBox.ItemsPanel>
    <ItemsPanelTemplate>
      <WrapPanel/>
    </ItemsPanelTemplate>
  </ListBox.ItemsPanel>

  <ListBox.ItemTemplate>
    <DataTemplate>
      <StackPanel Width="350" Height="250">
        <lvc:CartesianChart>
          <lvc:LineSeries Values="{Binding data}"/>
        </lvc:CartesianChart>
      </StackPanel>
     </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>
</StackPanel>

Solution

  • The reason why you don't get a vertical scrollbar is that you have put the ListBox in a StackPanel. A StackPanel measures its children with infinite vertical space if its Orientation property is set to Vertical:

    It's not scrollable vertically in case of LiveCharts in WrapPanel of WPF,