Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 绘制氧化图wpf_C#_Wpf_Oxyplot - Fatal编程技术网

C# 绘制氧化图wpf

C# 绘制氧化图wpf,c#,wpf,oxyplot,C#,Wpf,Oxyplot,我对波因特的画有意见。当我开始在oxyplot画布上绘制线条时,什么都没有发生。但当我开始超越oxyplot的边界时,它就起作用了。为什么它工作得这么奇怪?如何解决这个问题 <Window x:Class="WpfApplication18DrawProblem.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.micro

我对波因特的画有意见。当我开始在oxyplot画布上绘制线条时,什么都没有发生。但当我开始超越oxyplot的边界时,它就起作用了。为什么它工作得这么奇怪?如何解决这个问题

<Window x:Class="WpfApplication18DrawProblem.MainWindow"
    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:lib="clr-namespace:DrawToolsLib;assembly=DrawToolsLib"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <Canvas  Name="paintSurface" MouseDown="Canvas_MouseDown_1" MouseMove="Canvas_MouseMove_1" Grid.Column="1" Background="Transparent">
    </Canvas>
    <oxy:Plot Model="{Binding PlotModel}" Controller="{Binding PlotController}" Height="300" Width="300" Background="Transparent" Grid.Column="0"></oxy:Plot>
</Grid>

使用OxyPlot;
使用制度;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;
使用System.Windows.Shapes;
使用绘图工具SLIB;
命名空间WPFAApplication18DrawProblem
{
/// 
///MainWindow.xaml的交互逻辑
/// 
/// 
公共类测试数据
{
公共PlotModel PlotModel{get;set;}
私有OxyPlot.Series.LineSeries LS;
公共PlotController PlotController{get;set;}
公共测试数据()
{
PlotController=新的OxyPlot.PlotController();
PlotController.UnbindAll();
随机rnd=新随机();
PlotModel=新的PlotModel();
LS=新的OxyPlot.Series.LineSeries();
对于(int i=0;i<10;i++)
{
添加(新数据点(i,rnd.NextDouble());
}
PlotModel.Series.Add(LS);
}
公共无效更新()
{
PlotModel.InvalidatePlot(真);
}
}
公共部分类主窗口:窗口
{
点currentPoint=新点();
TestData TD=新的TestData();
公共主窗口()
{
DataContext=TD;
初始化组件();
}
私有void Canvas_MouseDown_1(对象发送器,System.Windows.Input.MouseButtonEventArgs e)
{
如果(e.ButtonState==MouseButtonState.Pressed)
currentPoint=e.GetPosition(此);
}
私有void Canvas_MouseMove_1(对象发送方,System.Windows.Input.MouseEventArgs e)
{
如果(e.LeftButton==鼠标按钮状态。按下)
{
行=新行();
椭圆Ell=新椭圆()
{
笔划=画笔。黑色,
冲程厚度=2,
};
line.Stroke=SystemColors.WindowFrameBrush;
line.X1=currentPoint.X;
line.Y1=当前点.Y;
line.X2=e.GetPosition(this).X;
line.Y2=e.GetPosition(this).Y;
currentPoint=e.GetPosition(此);
漆面。儿童。添加(线);
}
TD.Update();
}
}
}

XAML文件中元素的顺序在这里起作用。如果将绘图区域放置在
画布
区域之后/之上,则
画布
的该部分将隐藏以供用户输入

因此,这种情况下最简单的解决方案是切换XAML文件中
oxy:Plot
Canvas
元素的顺序:

...
<Grid>
  <oxy:Plot Model="{Binding PlotModel}" Controller="{Binding PlotController}" Height="300" Width="300" Background="Transparent" Grid.Column="0" />
  <Canvas Name="paintSurface" MouseDown="Canvas_MouseDown_1" MouseMove="Canvas_MouseMove_1" Grid.Column="1" Background="Transparent" />
</Grid>
。。。

如果更改XAML文件中
的顺序,会发生什么情况?是的,更改后工作正常,谢谢!
...
<Grid>
  <oxy:Plot Model="{Binding PlotModel}" Controller="{Binding PlotController}" Height="300" Width="300" Background="Transparent" Grid.Column="0" />
  <Canvas Name="paintSurface" MouseDown="Canvas_MouseDown_1" MouseMove="Canvas_MouseMove_1" Grid.Column="1" Background="Transparent" />
</Grid>