I was wondering if you could help me with something. I'm trying to get stacked plots like this picture.
I'm using UniformGrid
to try to get something like this, but it's not correct.
<UniformGrid x:Name="plots" Rows="2">
<StackPanel x:Name="plot1" IsEnabled="False" Visibility="Collapsed">
<Grid MinWidth="300" MinHeight="300">
<WpfPlot x:Name="hr_graph"/>
</Grid>
</StackPanel>
<StackPanel x:Name="plot2" IsEnabled="False" Visibility="Collapsed">
<Grid MinWidth="300" MinHeight="300" >
<WpfPlot x:Name="sat_graph"/>
</Grid>
</StackPanel>
<StackPanel x:Name="plot3" IsEnabled="False" Visibility="Collapsed">
<Grid MinWidth="300" MinHeight="300">
<WpfPlot x:Name="pul_graph"/>
</Grid>
</StackPanel>
<StackPanel x:Name="plot4" IsEnabled="False" Visibility="Collapsed">
<Grid MinWidth="300" MinHeight="300">
<WpfPlot x:Name="per_graph" />
</Grid>
</StackPanel>
</UniformGrid>
You can make this container just a generic
ItemsControl
, and change itsItemsPanel
according to number of visible panels.For example:
That's in plain xaml - I have a slider where you select number of panels to view and according to its value, I change
Visibility
of different panels andItemsPanel
as well.If you are changing
Visibility
in code-behind, then you can changeItemsPanel
ofItemsControl
in code-behind as well.So, when you need single panel you set it to simple
Grid
, if two panels:UniformGrid 1x2
, if three panels:Grid
with two equal rows and two equal columns and pay attention onGrid.Row
,Grid.Column
,Grid.ColumnSpan
properties defined on panels. For four panels we useUniformGrid 2x2
.Hope, that helps.
Important: This will only work if your panels should always be in same order, and for example
Part3
can't be visible if `Part2' is hidden. Otherwise, it's a bit more tricky - you will need to dynamically assigned content to parts.UPD: To view
DataTemplate
on window you can useContentControl
: