2012-02-07 11 views
1

ウィンドウ内に動的に描画する四角形があります。このウィンドウには、不透明度が0.4に設定された背景があります。 私は矩形内の領域を完全に透明にしたいと思っています(ウィンドウの背景を見てください)。矩形を完全に透明にしました(ウィンドウ内の穴)WPF

これを行う方法はありますか?

<Window x:Class="TakeAScreenzone" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="PloofTAS" Height="355" Width="539" Topmost="True" 
    ResizeMode="NoResize" AllowsTransparency="True" 
    ShowInTaskbar="False" ShowActivated="True" WindowStyle="None" Background="#66FFFFFF" > 
    <Grid Name="Grid1"></Grid> 
</Window> 

そして、ここで私は私の四角形を描画するために使用するコード(GRID1は私の窓のメイングリッドである。)::

WorkingRectangle = New Rectangle 
     WorkingRectangle.Stroke = New SolidColorBrush(Colors.Red) 
     WorkingRectangle.StrokeThickness = 1 
     WorkingRectangle.Fill = Nothing 
     WorkingRectangle.HorizontalAlignment = Windows.HorizontalAlignment.Left 
     WorkingRectangle.VerticalAlignment = Windows.VerticalAlignment.Top 
     Grid1.Children.Add(WorkingRectangle) 
+0

ウィンドウには、40%の不透明度である、または矩形はありますか? –

+0

ウィンドウの背景色。私はウィンドウ内のスナップショットツールと同じレンダリングをしようとしています。 –

+0

清算に感謝します –

答えて

4

私はあなたが(ここで私は、ウィンドウの中央に長方形の穴を作成しました)次のアプローチを利用することができ、信じる:

<Window x:Class="WpfApplication1.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="PloofTAS" Height="355" Width="539" Topmost="True" 
ResizeMode="NoResize" AllowsTransparency="True" 
ShowInTaskbar="False" ShowActivated="True" WindowStyle="None" Background="Transparent"> 
    <Grid Name="Grid1"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="*" /> 
      <RowDefinition Height="*" /> 
      <RowDefinition Height="*" /> 
     </Grid.RowDefinitions> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="*" /> 
     </Grid.ColumnDefinitions> 
     <Rectangle Fill="#66FFFFFF" Grid.Column="0" Grid.RowSpan="3"/> 
     <Rectangle Fill="#66FFFFFF" Grid.Column="2" Grid.RowSpan="3"/> 
     <Rectangle Fill="#66FFFFFF" Grid.Column="1" Grid.Row="0"/> 
     <Rectangle Fill="#66FFFFFF" Grid.Column="1" Grid.Row="2"/> 
     <Rectangle x:Name="workingRectangle" Fill="Transparent" Stroke="Red" Grid.Column="1" Grid.Row="1"/> 
    </Grid> 
</Window> 
0

くださいここ

は私の窓のコードです内側の矩形はOpacity Maskです。

+0

もっと正確になりますか?私は自分のコードで私の最初の投稿を編集します。 私は記事を読んだが、それを動作させるために何をすべきか分からなかった。 –

+0

-1:7ワードは答えではありません。 –

関連する問題