0

Flipview で画像を表示する必要があるギャラリー アプリに取り組んでいます。Flipview の場合、画像をズームイン/ズームアウトしたいと思います。これは、画像を表示して複合変換を実行しようとしている私のコードです。

<Image Source="Assets/WP_20150914_11_30_50_Pro.jpg"
                Stretch="Uniform"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                RenderTransformOrigin="0.5,0.5"
                ManipulationDelta="img_intro_ManipulationDelta"
                ManipulationMode="All">
            <Image.RenderTransform>
                <CompositeTransform/>
            </Image.RenderTransform>
        </Image>

private void img_intro_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
        {
            Image img = sender as Image;

            CompositeTransform ct = img.RenderTransform as CompositeTransform;

            ct.ScaleX *= e.Delta.Scale;
            ct.ScaleY *= e.Delta.Scale;

            if (ct.ScaleX < 1.0) ct.ScaleX = 1.0;
            if (ct.ScaleY < 1.0) ct.ScaleY = 1.0;
            if (ct.ScaleX > 4.0) ct.ScaleX = 4.0;
            if (ct.ScaleY > 4.0) ct.ScaleY = 4.0;

            ct.TranslateX += e.Delta.Translation.X;
            ct.TranslateY += e.Delta.Translation.Y;

            if (ct.TranslateY > (((img.ActualHeight * ct.ScaleY) - img.ActualHeight) / 2))
            {
                ct.TranslateY = (((img.ActualHeight * ct.ScaleY) - img.ActualHeight) / 2);
            }

            if (ct.TranslateY < 0 - ((((img.ActualHeight * ct.ScaleY) - img.ActualHeight)) / 2))
            {
                ct.TranslateY = 0 - ((((img.ActualHeight * ct.ScaleY) - img.ActualHeight)) / 2);
            }

            if (ct.TranslateX > (((img.ActualWidth * ct.ScaleX) - img.ActualWidth) / 2))
            {
                ct.TranslateX = (((img.ActualWidth * ct.ScaleX) - img.ActualWidth) / 2);
            }

            if (ct.TranslateX < 0 - ((((img.ActualWidth * ct.ScaleX) - img.ActualWidth)) / 2))
            {
                ct.TranslateX = 0 - ((((img.ActualWidth * ct.ScaleX) - img.ActualWidth)) / 2);
            }             
        }

これは、Flipview がなくてもうまく機能します。しかし、それをフリップビューに追加すると、次のアイテムまたは前のアイテムにフリップできなくなります。

これを修正する方法はありますか?

4

1 に答える 1

0

操作デルタを使用するのではなく、UI スレッドで操作が発生するたびにイベントを発生させないため、画像をスクロールビューアー内に配置します。

のようなことを試してください

<Flipview>
<ScrollViewer MaxZoomFactor="4">
<Image>
</Image>
</Scrollviewer>
</Flipview>

m は現在 IDE を持っていないので、これが最善の解決策です。試してみて、私に知らせてください。

于 2015-09-16T06:53:31.480 に答える