我无法让 Oxyplot 热图在我的 WPF 项目中工作知道我做错了什么吗?

问题描述

我只是尝试使用存储在 Cpdata 中的二维数据数组来绘制热图系列。我省略了对问题没有用的部分。我是 wpf 和 oxyplot 的新手,想象一下我只是在某处绑定出错了。 xaml 代码也在下面并简化了。

目前我在运行项目时看到一个空白窗口。 如果有任何不清楚的地方,请告诉我,谢谢!

<Window x:Class="Project.Flowfield"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:oxy="http://oxyplot.org/wpf"
        xmlns:local="clr-namespace:Project"
        Title="Flowfield" Height="850" Width="1200" MinHeight="700" MinWidth="330" 
    <Window.DataContext>
        <local:OxyPlotModel/>
    </Window.DataContext>  

<Grid>

       <oxy:PlotView x:Name="Cpheatmap"  Model="{Binding PlotModel}">
                   
       </oxy:PlotView>
</Grid>
using OxyPlot;
using OxyPlot.Series;
using OxyPlot.Axes;

namespace Project
{
    public class OxyPlotModel : INotifyPropertyChanged
    {
        private OxyPlot.PlotModel plotModel; //field
        public OxyPlot.PlotModel PlotModel  //property
        {
            get
            {
                return plotModel;
            } //get method
            set
            {
                plotModel = value;
                OnPropertyChanged("PlotModel");
            }  //set method
        }

        public OxyPlotModel()
        {
            PlotModel = new PlotModel();
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler!= null)
            {
                handler(this,new PropertyChangedEventArgs(name));
            }
        }
    }
    

    public partial class Flowfield : Window
    {
        private OxyPlotModel oxyPlotModel;
        
        public Flowfield()
        {
            oxyPlotModel = new OxyPlotModel();
            DataContext = oxyPlotModel;
            InitializeComponent();
            
           
        }
        
        public double[,] Cpdata = new double[50,50];
 
        public void RunCommand()
        {
            //...
            //Cpdata is a 2D array calculated from another method (skipped because irrelevant) 
            //...

            var oxyPlotModel = new PlotModel();
            var hms = new HeatMapSeries { Data = Cpdata};
            oxyPlotModel.Series.Add(hms);
            DataContext = this;
        }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)