我正在通过单击按钮来进行放大,就像使用鼠标滚动一样。我尝试为MinValue
轴设置MaxValue
和X
,但是当我这样做时,使用鼠标滚动进行缩放时会中断,并停止更新MinValue
和MaxValue
。如何在不中断鼠标滚动缩放的情况下进行放大?
private double? _minX;
public double? MinX {
get => _minX;
set => SetValue(ref _minX, value);
}
public void ZoomIn()
{
if (MinX == null || MaxX == null)
return;
MaxX -= 1000;
MinY = null;
MaxY = null;
}
我的观点:
<Button Content="+" Width="25" Height="25" Margin="2" cal:Message.Attach="[Event Click] = [ZoomIn()]"></Button>
<lvc:CartesianChart Series="{Binding SeriesCollection}" Zoom="X" Pan="X">
<lvc:CartesianChart.AxisX>
<lvc:Axis MinValue="{Binding MinX, FallbackValue=0}" MaxValue="{Binding MaxX, FallbackValue=100}"
LabelFormatter="{Binding FormatterX}"></lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
答案 0 :(得分:1)
我知道了。我必须将Mode=TwoWay
设置为轴:
<lvc:CartesianChart.AxisX>
<lvc:Axis MinValue="{Binding MinX, Mode=TwoWay}" MaxValue="{Binding MaxX, Mode=TwoWay}"
LabelFormatter="{Binding FormatterX}"></lvc:Axis>
</lvc:CartesianChart.AxisX>