0

I want to put several graphs in one WPF window using OXYplot library, so there will be some WPF components (like buttons) and some rectangles with graphs. It there a way to do it? In all examples the OXYplot graph occupies the whole WPF window.

I tried to put it inside a rectangle like this, but got an error "The type 'Rectangle' does not support direct content"

<Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="100" Margin="932,547,0,0" Stroke="Black" VerticalAlignment="Top" Width="100">
   <oxy:PlotView Model="{Binding Model}"/>
</Rectangle>
Perotto
  • 194
  • 1
  • 14
  • See [Panels Overview](https://learn.microsoft.com/en-us/dotnet/framework/wpf/controls/panels-overview). – Clemens Feb 10 '20 at 11:02

2 Answers2

1

Put it in a Panel or decorate it with a a Border:

<Border Background="Yellow" BorderBrush="Black" BorderThickness="1" Padding="10">
    <oxy:PlotView Model="{Binding Model}"/>
</Border>

A PlotView is just a custom Control that you can use in your layout as you would use any other control in WPF.

mm8
  • 163,881
  • 10
  • 57
  • 88
0

To keep it simple, you could use Grid as well, to arrange multiple PlotView and buttons in desired layout.

<Grid Margin="10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Column="0" Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <oxy:PlotView Height="500" Width="500" Model="{Binding GraphModel1}"/>
            <Button Grid.Column="1" Content="Click"/>
        </Grid>
        <Grid Grid.Column="1" Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <oxy:PlotView Height="500" Width="500" Model="{Binding GraphModel2}"/>
            <Button Grid.Column="1" Content="Click"/>
        </Grid>
        <Grid Grid.Column="1" Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <oxy:PlotView Height="500" Width="500" Model="{Binding GraphModel3}"/>
            <Button Grid.Column="1" Content="Click"/>
        </Grid>
        <Grid Grid.Column="0" Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <oxy:PlotView Height="500" Width="500" Model="{Binding GraphModel4}"/>
            <Button Grid.Column="1" Content="Click"/>
        </Grid>
    </Grid>
Anu Viswan
  • 17,797
  • 2
  • 22
  • 51