1
我有這款益智遊戲,我可以在遊戲區中看電影。C#通用應用程序:拖動時前景圖像
我最近添加了觸摸屏的方式來做到這一點,它的工作原理,但有一個問題。 當我將圖像從一個地方移動到另一個地方時,拖動的圖像位於背景中,其他圖像位於前景中,我希望以其他方式獲取圖像,請參閱屏幕截圖。 1
我δ函數是這樣的:
public void Touch_Delta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
{
Image img_touched = (Image)sender;
TranslateTransform _Transform = (img_touched.RenderTransform = (img_touched.RenderTransform as TranslateTransform) ?? new TranslateTransform()) as TranslateTransform;
_Transform.X += e.Delta.Translation.X;
_Transform.Y += e.Delta.Translation.Y;
if(_Transform.X > 90.0)
{
img_touched.RenderTransform = null;
Move_Right(this, null);
}
else if(_Transform.X < -90)
{
img_touched.RenderTransform = null;
Move_Left(this, null);
}
else if (_Transform.Y > 90.0)
{
img_touched.RenderTransform = null;
Move_Down(this, null);
}
else if (_Transform.Y < -90.0)
{
img_touched.RenderTransform = null;
Move_Up(this, null);
}
Rotate_Touch += e.Delta.Rotation;
if(Rotate_Touch > 55.0)
{
Rotate_Right(this, null);
Rotate_Touch = 0;
}
else if(Rotate_Touch < -55.0)
{
Rotate_Left(this, null);
Rotate_Touch = 0;
}
}
相應的XAML是:
<UserControl
x:Class="PictureSplitter.Views.PictureView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="768"
d:DesignWidth="1024">
<Grid Height="1000" Width="600" Background="Black">
<GridView ItemsSource="{Binding Splitter.PuzzlePositions}" Background="Black">
<GridView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF888E91" BorderThickness="2" Background="Black">
<Grid Name="picGrid" Background="Black" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image Source="{Binding Piece.ImageSource}" Tapped="Image_Tapped" ManipulationMode="All" CanDrag="False" Loaded="Load_Events" />
</Grid>
</Border>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Grid>
</UserControl>
我知道有在Windows.Canvas事情Z-索引,但我還沒有找到這裏的東西類似。有沒有辦法做到這一點?
你是對的,從左至右移動都會使它消失,從右到左使得它在其他圖像上移動。 – fsp