2011-04-18 41 views
11

我試着和它設置一個新的邊界網格邊框上方:如何製作圓角轉角網格?

<Window x:Class="Class.Window" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Window1" Width="379" Loaded="Window_Loaded" 
     AllowsTransparency="True" 
     ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True" WindowStyle="None" Height="110">  
    <Border BorderBrush="Black" BorderThickness="1,1,1,1" CornerRadius="30,30,30,30"> 
     <Grid> 
      <TextBlock Height="23" HorizontalAlignment="Left" Margin="62,12,0,0" Name="textBlock_From" Text="" VerticalAlignment="Top" Width="283" /> 
      <TextBlock Height="23" HorizontalAlignment="Left" Margin="62,38,0,0" Name="textBlock_Subject" Text="" VerticalAlignment="Top" Width="283" 
         MouseLeftButtonDown="textBlock_Subject_MouseLeftButtonDown" MouseEnter="textBlock_Subject_MouseEnter" MouseLeave="textBlock_Subject_MouseLeave" /> 
     </Grid> 
    </Border> 
</Window> 
+1

一個電網本身沒有邊界,所以要麼你把一個放在裏面,要麼就像你一樣。由於這個問題不是很清楚,所以我只能回覆:_like you did_ – 2011-04-18 08:02:40

回答

25

因爲它是不完全清楚你正在嘗試做的,我想你想的圓角和透明背景的窗口。您的解決方案是正確的,您只需設置Window背景透明度和Border的背景。

<Window x:Class="Class.Window" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window1" Width="379" Loaded="Window_Loaded" 
    AllowsTransparency="True" 
    ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True" WindowStyle="None" Height="110" Background="Transparent">  
    <Border Background="White" BorderBrush="Black" BorderThickness="1,1,1,1" CornerRadius="30,30,30,30"> 
     <Grid> 
      <TextBlock Height="23" HorizontalAlignment="Left" Margin="62,12,0,0" Name="textBlock_From" Text="" VerticalAlignment="Top" Width="283" /> 
      <TextBlock Height="23" HorizontalAlignment="Left" Margin="62,38,0,0" Name="textBlock_Subject" Text="" VerticalAlignment="Top" Width="283" 
        MouseLeftButtonDown="textBlock_Subject_MouseLeftButtonDown" MouseEnter="textBlock_Subject_MouseEnter" MouseLeave="textBlock_Subject_MouseLeave" /> 
     </Grid> 
    </Border> 
</Window> 
+1

如何爲圓角的整個網格創建漸變背景?這僅適用於邊框具有與背景相同的純色。 – Johncl 2011-11-23 12:03:17

+0

Johncl你是絕對正確的,如果填充漸變的邊界比網格背景還填充透明度不工作。 – 2015-07-15 06:24:27