[英]OxyPlot WPF - Get slected column
我正在尝试在OxyPlot WPF中选择(单击)列。 有没有办法做到这一点? 到目前为止我的WPF代码:
<oxy:Plot x:Name="plotDiagram" Title="Output" >
<oxy:Plot.Axes>
<oxy:CategoryAxis ItemsSource="{Binding Item.barDisplayData1}" LabelField="DisplayText"/>
<oxy:LinearAxis MinimumPadding="0" AbsoluteMinimum="0"/>
</oxy:Plot.Axes>
<oxy:Plot.Series>
<oxy:ColumnSeries Title="{Binding Item.Title1}" FillColor="Green" IsStacked="True" ItemsSource="{Binding Item.barDisplayData1}" ValueField="Value" />
<oxy:ColumnSeries Title="{Binding Item.Title2}" FillColor="Red" IsStacked="True" ItemsSource="{Binding Item.barDisplayData2}" ValueField="Value"/>
<oxy:ColumnSeries Title="{Binding Item.Title3}" FillColor="Yellow" IsStacked="True" ItemsSource="{Binding Item.barDisplayData3}" ValueField="Value"/>
</oxy:Plot.Series>
</oxy:Plot>
没有选定的列属性。 您需要在列系列上实现mousedown事件,并使用GetNearestPoint()函数确定单击了哪个列。
void columns_MouseDown(object sender, MouseButtonEventArgs e)
{
var cols = sender as ColumnSeries;
OxyMouseDownEventArgs args = ConverterExtensions.ToMouseDownEventArgs(e, sender);
if (cols != null)
{
TrackerHitResult nearestPoint = cols.GetNearestPoint(args.Position, false);
if(nearestPoint != null) {
object selectedColumn = nearestPoint.Item;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.