windows-8 - WinRT 中等效的路径几何裁剪

标签 windows-8 windows-runtime winrt-xaml

今天我开始移植创建的翻页示例 here适用于 Windows Phone 7 到 WinRT(XAML、C#)的帮助 this在 Stack Overflow 上发布的问题。但是在移植过程中,我被页面的剪辑部分卡住了。在 windows phone 示例中,他们使用路径几何裁剪来裁剪页面。但在 WinRT 中,似乎只有矩形几何图形支持裁剪选项。

如何在 WinRT 中实现类似路径几何裁剪的功能?

您可以从 here 下载示例 windows 电话代码

请找到我试过的源代码please download

在那请找到PageTurn.cs类,我在代码中评论了问题,在:

void left_PointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
    //_workingOdd.Clip = _oddClipRegion;       
    //_workingEven.Clip = _evenClipRegion;
}

最佳答案

希望这对您有所帮助。

这是 XAML,可准确获取您链接到的演示的外观:

路径计算
enter image description here

图片1

 <Grid Background="Black">
    <Grid Height="145" Width="210" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Border Margin="-3" BorderThickness="3" BorderBrush="White" Grid.ColumnSpan="2"></Border>
        <Image Grid.Column="0" Source="Images/1.jpg"></Image>
        <Image Grid.Column="1" Source="Images/2.jpg" ></Image>
        <Image Grid.Column="1" HorizontalAlignment="Left"  Source="Images/8.jpg" >
            <Image.Clip>
                <RectangleGeometry Rect="0,0,49,150"></RectangleGeometry>
            </Image.Clip>
        </Image>
        <Path Grid.ColumnSpan="2"  Data="M 180,0 L 153,145 L 85 120 L 160,-12"   >
            <Path.Fill>
                <ImageBrush ImageSource="Images/4.jpg"/>
            </Path.Fill>
        </Path>
        <!--polyline used for path image border-->
        <Polyline Points="180,0,160,-11,85,120,153,145" Margin="0,-2,0,0"  Stroke="White" StrokeThickness="3"  Grid.ColumnSpan="2"/>
    </Grid>
</Grid>

图片2
    <Grid Background="Black">
    <Grid Width="290" Height="180" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Border Grid.Column="0"  BorderThickness="2,0,0,0" BorderBrush="White">
            <Image Stretch="Fill"  Source="Images/4.jpg"></Image>
        </Border>
        <Image Grid.Column="1" Source="Images/3.jpg" ></Image>
        <Path Grid.ColumnSpan="2"  Data="M 200,0 L 170,180 L 82.5 160 L 130 0 "   >
            <Path.Fill>
                <ImageBrush ImageSource="Images/6.jpg"/>
            </Path.Fill>
        </Path>
        <!--polyline used for path image border-->
        <Polyline Points="130,0,82.5,160,170,180"   Stroke="White" StrokeThickness="2"  Grid.ColumnSpan="2"/>
    </Grid>
</Grid>

输出

enter image description here

您可以通过将 image1 和 image2 网格放在 View 框中来放大图像的大小,如下所示
 <Viewbox Width="500" Height="350">
    <Grid Width="290" Height="180"/>        
 </Viewbox>

关于windows-8 - WinRT 中等效的路径几何裁剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22905589/

相关文章:

c# - 如何在 Windows Universal 10 App 中无异常地获取 StackTrace

c# - 如何在 Windows 8.1 (winRT) 中获取本地文件夹大小

c# - WinRTXamlToolkit.Controls.DataVisualization.Charting 不适用于 .appx bundle

windows-8 - VS 调试到 Windows Phone 设备?

javascript - 将 HTML 页面从 JavaScript 转换为 PDF

c# - 下载异步错误。在意外的时间调用了一个方法

c++ - 将 SQLite 与 WinRT 结合使用

windows-8 - Windows 运行时 UI 组件

javascript - 在不使用 aria-haspop 的情况下模拟 Windows 表面上的触摸

java - 使用 Java 创建 Windows Metro 风格的应用程序?