XAML код ниже
<Window x:Class="DenemeWpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DockPanel Width="Auto"
VerticalAlignment="Stretch"
Height="Auto"
HorizontalAlignment="Stretch"
Grid.ColumnSpan="1"
Grid.Column="0"
Grid.Row="0"
Margin="0,0,0,0"
Grid.RowSpan="1">
<StackPanel>
<StackPanel.Background>
<LinearGradientBrush>
<GradientStop Color="White" Offset="0" />
<GradientStop Color="DarkKhaki" Offset=".3" />
<GradientStop Color="DarkKhaki" Offset=".7" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</StackPanel.Background>
<StackPanel Margin="10">
<Button Name="simpleButton"
Click="simpleButtonClick"
KeyDown="simpleButton_KeyDown">Simple</Button>
<Button Name="cubeButton"
Click="cubeButtonClick">Cube</Button>
</StackPanel>
</StackPanel>
<Viewport3D Name="mainViewport"
ClipToBounds="True">
<Viewport3D.Camera>
<PerspectiveCamera FarPlaneDistance="100"
LookDirection="-11,-10,-9"
UpDirection="0,1,0"
NearPlaneDistance="1"
Position="11,10,9"
FieldOfView="70" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight Color="White" Direction="-2,-3,-1" />
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
</DockPanel>
</Grid>
</Window>
это внутри XAML.cs
private void simpleButton_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.P) {
//something to move the simpleButton
}
}
Я хочу переместить simpleButton
, когда P нажимается на клавиатуре, но я не могу найти какой-либо способ или способ сделать это.