繁体   English   中英

有没有办法在 WPF 窗口的自定义区域中绘制 OXYplot 图?

[英]Is there a way to plot OXYplot graph in custom area in WPF window?

我想使用 OXYplot 库将多个图形放在一个 WPF 窗口中,因此会有一些 WPF 组件(如按钮)和一些带有图形的矩形。 它有办法做到吗? 在所有示例中,OXYplot 图占据了整个 WPF 窗口。

我试图将它放在这样的矩形内,但出现错误“'矩形'类型不支持直接内容”

<Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="100" Margin="932,547,0,0" Stroke="Black" VerticalAlignment="Top" Width="100">
   <oxy:PlotView Model="{Binding Model}"/>
</Rectangle>

把它放在一个Panel 中或用 aa Border装饰它:

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

一个PlotView仅仅是一个自定义的Control ,你可以在你的布局中使用,你会使用WPF任何其他控制。

为简单起见,您也可以使用 Grid,在所需的布局中排列多个 PlotView 和按钮。

<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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM