wpf oxyplot PlotAreaBackground 图像

wpf oxyplot PlotAreaBackground image

我想要彩色背景。我的代码不起作用。版本 OxyPlotWpf:1.0.0-unstable2100。发布日期:2016 年 4 月 12 日,星期二 (4/12/2016)

想不到你还能写的详细点,我的问题没有通过是因为系统认为不够详细,所以我加了正文(sorry)

我有什么

我想要什么

我的GrpahPhone.png

<Window x:Class="OxiPlotTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:OxiPlotTest"
    xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
    xmlns:oxy2="http://oxyplot.codeplex.com"
    mc:Ignorable="d"
    Title="MainWindow" Height="250" Width="750"
    Background="#333333">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="200"/>
    </Grid.RowDefinitions>

    <oxy:Plot Grid.Row="0" x:Name="oxyPlot2" Title="" Margin="10" Background="Transparent" PlotAreaBorderThickness="0,0,0,1" PlotAreaBorderColor="#CCCCCC">
        <oxy:Plot.Axes>
            <oxy:LinearAxis Position="Left" Minimum="0" Maximum="100" MajorGridlineColor="#333333" MajorGridlineStyle="Solid" MajorGridlineThickness="1" MajorStep="25" MinorStep="25"
                            TickStyle="None" TextColor="#CCCCCC" FontSize="16" FontWeight="Bold" AxisDistance="5"/>
            <oxy:LinearAxis Position="Bottom" Minimum="0" Maximum="5" MajorGridlineStyle="None" MajorStep="1" MinorStep="1"
                            TextColor="#CCCCCC" FontSize="16" FontWeight="Bold" TicklineColor="#CCCCCC"/>
        </oxy:Plot.Axes>
        <oxy:Plot.Series>
            <oxy:LineSeries ItemsSource="{Binding Points}" Color="AliceBlue" StrokeThickness="4"/>
        </oxy:Plot.Series>
    </oxy:Plot>
</Grid>

public partial class MainWindow : Window
{

    public IList<DataPoint> Points { get; private set; }

    public MainWindow()
    {
        InitializeComponent();


        Points = new List<DataPoint>
        {
            new DataPoint(0, 5),
            new DataPoint(1, 40),
            new DataPoint(2, 55),
            new DataPoint(3, 80),
            new DataPoint(4, 90),
            new DataPoint(5, 50),
        };

        DataContext = this;

        BitmapImage bitmapImage = new BitmapImage();
        bitmapImage.BeginInit();
        bitmapImage.UriSource = new Uri("pack://application:,,,/OxiPlotTest;component/Resources/GraphFon.png", UriKind.Absolute);
        bitmapImage.EndInit();

        var encoder = new PngBitmapEncoder();
        encoder.Frames.Add(BitmapFrame.Create((BitmapImage)bitmapImage));
        var stream = new System.IO.MemoryStream();
        encoder.Save(stream);
        stream.Flush();
        var image = new System.Drawing.Bitmap(stream);

        var bitmap = new System.Drawing.Bitmap(image);
        var bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
        bitmap.Dispose();
        var brush = new ImageBrush(bitmapSource);

        oxyPlot2.PlotAreaBackground = brush;
    }
} 

我按颜色制作了 5 个不同的列表点并添加了 LineSeries