2017-05-29 16 views
1

我正在嘗試爲ZXing.Mobile製作自定義取景器。它應該類似於dm77(Android庫)的取景器。在原來它看起來像下面的圖片:XAML自定義網格邊框(相機取景器類似於dm77)

原始取景畫面 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> 

怎樣才能讓視邊框看起來完全一樣在圖片上做什麼?

+0

將圖像轉換爲PNG格式,黑色部分爲透明,並使用該圖像而不是創建自己的效果。這將是容易的。 –

+0

我一直在想它。但是邊框必須能夠響應不斷變化的屏幕大小。在這種情況下,圖片將不起作用。 – denisyfrolov

+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> 
+0

這正是我一直在尋找的。非常感謝! – denisyfrolov

+0

@denisyfrolov這是我的榮幸 –