当我按下 -> 时,我想向右移动画布。我设置了事件 KeyDown,这是事件的方法
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key==Key.Right)
{
}
}
但是里面写什么if
呢?Canvas.setLeft
不工作
<Canvas x:Name="totle" KeyDown="Window_KeyDown">
<Ellipse Name="yio" Canvas.Left="40" Canvas.Top="40" Height="30" Width="30" Fill="Beige"/>
<Line X1="40" Canvas.Left="67" Canvas.Top="51" StrokeThickness="40" Stroke="Red" Height="10" Width="45" Fill="#FFD86464" OpacityMask="Red" />
<Rectangle Canvas.Left="20" Canvas.Top="70" Width="70" Height="20" Fill="Beige"/>
</Canvas>