locked
Help: ScrollViewer Content Clipped issue RRS feed

  • 问题

  • I add Canvas in ScrollViewer, and set Canvas Clip like below code. But the content will be clipped, I am confused. Please help me.

                for (int i = 0; i < 10; ++i)
                {
                    Canvas canvas = new Canvas();
                    canvas.Width = 456;
                    canvas.Height = 456;
                    RectangleGeometry clipRect = new RectangleGeometry();
                    clipRect.Rect = new Rect(0, 0, 456, 456);
                    clipRect.RadiusX = 8;                       
                    clipRect.RadiusY = 8;                      
                    canvas.Clip = clipRect;
                    Image image = new Image();
                    image.Width = 456;
                    image.Height = 456;
                    image.Stretch=Stretch.Fill;
                    image.Source = new BitmapImage(new Uri("/ApplicationIcon.png", UriKind.Relative));
                    canvas.Children.Add(image);
                    scrollContent.Children.Add(canvas);
                }
            }

    Result:


    SlickDroid

    • 已移动 Cheryl_WPS 2012年12月31日 19:47 移动 (发件人:Windows Phone Dev Center 论坛)
    2012年12月27日 6:27

答案

  • 你好,

    你的代码看上去没有什么问题,For循环创建的对象均在同一个位置上。所以我这边的运行结果是:

    这是前台代码:

     <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <ScrollViewer Height="500" HorizontalAlignment="Left"  Name="scrollviewer" VerticalAlignment="Top" Width="400" >
                    <Grid x:Name="scrollContent" Width="480" Height="200"></Grid>
                </ScrollViewer>
            </Grid>

    没有重现你的问题,请问你的预期效果是?


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2013年1月1日 7:07
    版主

全部回复

  • 你好,

    你的代码看上去没有什么问题,For循环创建的对象均在同一个位置上。所以我这边的运行结果是:

    这是前台代码:

     <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <ScrollViewer Height="500" HorizontalAlignment="Left"  Name="scrollviewer" VerticalAlignment="Top" Width="400" >
                    <Grid x:Name="scrollContent" Width="480" Height="200"></Grid>
                </ScrollViewer>
            </Grid>

    没有重现你的问题,请问你的预期效果是?


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2013年1月1日 7:07
    版主
  • 我将标记我的回复为答案,如果不能解决您的问题,请随时取消标记。谢谢。

    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2013年1月7日 3:28
    版主