【问题标题】:Windows phone 8.1 flip view issueWindows phone 8.1 翻转视图问题
【发布时间】:2015-09-16 02:33:49
【问题描述】:

我正在开发一个画廊应用程序,我需要在 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 的情况下运行良好。但是当我将它添加到翻转视图时,我将无法翻转到下一个项目或上一个项目。

有什么建议可以解决这个问题吗?

【问题讨论】:

    标签: c# windows-phone-8 windows-phone-8.1 windows-phone flipview


    【解决方案1】:

    而不是使用操作增量将图像放在滚动查看器中,因为它不会每次都触发事件以在 ui 线程上发生操作。

    尝试一些类似的东西

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

    由于 m 目前没有 IDE,这是最好的帮助,请尝试并告诉我。

    【讨论】:

    • 试过这个。它没有提供原生画廊缩放效果。此外,还有很多相关的问题,比如如果在横向模式下单击图像,那么在纵向模式下缩放相同的图像会将图片推到左上角。
    • 尝试将翻转视图放在滚动查看器中,让翻转视图在缩放时增大。还可以获得幻灯片效果。建议
    • 不起作用。 Flipview 的问题在于,如果我们将 ManipulationMode 设置为 Image 中的任何内容,则 FlipView 不会让我们滑动到下一个图像。在滚动查看器中使用 Flipview 对这种情况没有帮助。
    • 你使用的翻转视图的高度和宽度是多少?
    • 高度和宽度未设置。它的汽车。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-07
    • 2015-11-13
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多