XAML自定义网格边框(类似于dm77的相机取景器)

时间:2017-05-29 18:06:05

标签: c# xaml camera uwp zxing.net

我正在尝试为ZXing.Mobile制作自定义取景器。它应该类似于dm77(Android库)的取景器。原文如下图所示:

原始ViewFinder图片 original viewfinder picture

我有视图的下一个XAML定义:

<Grid Name="Overlay" Visibility="Visible">
    <Grid Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="2*" />
            <RowDefinition Height="2*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.1*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="0.1*"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Row="1" Grid.Column="1" >
            <Rectangle Stroke="Green" StrokeThickness="4" StrokeDashArray="2" />
        </Grid>
    </Grid>
</Grid>

如何使视图边框看起来与图片上的完全相同?

1 个答案:

答案 0 :(得分:1)

尝试这些代码行。根据需要更改值。

<Grid Width="500" Height="500">
    <Line Stroke="Yellow" StrokeThickness="5" X2="100" HorizontalAlignment="Left" VerticalAlignment="Top"/>
    <Line Stroke="Yellow" StrokeThickness="5" Y2="100" HorizontalAlignment="Left" VerticalAlignment="Top"/>
    <Line Stroke="Yellow" StrokeThickness="5" X2="100" HorizontalAlignment="Right" VerticalAlignment="Top"/>
    <Line Stroke="Yellow" StrokeThickness="5" Y2="100" HorizontalAlignment="Right" VerticalAlignment="Top"/>
    <Line Stroke="Yellow" StrokeThickness="5" X2="100" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
    <Line Stroke="Yellow" StrokeThickness="5" Y2="100" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
    <Line Stroke="Yellow" StrokeThickness="5" X2="100" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
    <Line Stroke="Yellow" StrokeThickness="5" Y2="100" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
    <Line Stroke="Red" StrokeThickness="5" X2="500" VerticalAlignment="Center"/>
</Grid>