2014-02-09 26 views
0

如果您測試下面的代碼和任何明亮的圖像,您會看到在所用圖像上繪製了4列和4行。我需要這種配置來使用某種效果。 基本上我做了它,它的工作原理,但我想刪除這些網格線,不知道如何。這可能與網格控件本身的實現有關嗎? 網格的屬性ShowGridlines是false。爲什麼基於網格的可視化畫筆顯示水平和垂直網格線

有可能使用Canvas而不是網格並手動進行放置,但我想繼續使用Grid並使用Canvas作爲最後的解決方案。

<Image Source="/Image1.tif" Visibility="Visible" > 
     <Image.OpacityMask> 
      <VisualBrush x:Name="DissolveInBrush" TileMode="None" > 
       <VisualBrush.Visual> 
        <Grid> 
         <Grid.ColumnDefinitions> 
          <ColumnDefinition Width="50" /> 
          <ColumnDefinition Width="50" /> 
          <ColumnDefinition Width="50" /> 
          <ColumnDefinition Width="50" /> 
         </Grid.ColumnDefinitions> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="50" /> 
          <RowDefinition Height="50" /> 
          <RowDefinition Height="50" /> 
          <RowDefinition Height="50" /> 
         </Grid.RowDefinitions> 
         <Rectangle Grid.Column="0" Grid.Row="0" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="1" Grid.Row="0" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="2" Grid.Row="0" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="3" Grid.Row="0" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="4" Grid.Row="0" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 

         <Rectangle Grid.Column="0" Grid.Row="1" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="1" Grid.Row="1" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="2" Grid.Row="1" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="3" Grid.Row="1" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="4" Grid.Row="1" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 

         <Rectangle Grid.Column="0" Grid.Row="2" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="1" Grid.Row="2" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="2" Grid.Row="2" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="3" Grid.Row="2" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="4" Grid.Row="2" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 

         <Rectangle Grid.Column="0" Grid.Row="3" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="1" Grid.Row="3" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="2" Grid.Row="3" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="3" Grid.Row="3" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
         <Rectangle Grid.Column="4" Grid.Row="3" Fill="#FF000000" StrokeThickness="0" Stroke="Transparent"/> 
        </Grid> 
       </VisualBrush.Visual> 
      </VisualBrush> 
     </Image.OpacityMask> 
    </Image> 

回答

0

您可以將RenderOptions.EdgeMode屬性設置爲Aliased在網格上,以避免這種影響:

<VisualBrush x:Name="DissolveInBrush" TileMode="None" > 
    <VisualBrush.Visual> 
     <Grid RenderOptions.EdgeMode="Aliased"> 
      ... 
     </Grid> 
    </VisualBrush.Visual> 
</VisualBrush> 
+0

大,它的工作!它刪除了邊緣。 – Patrik