2016-08-10 47 views
-1

您好希望使用WPF主窗口中的拐角半徑。但是當我使用邊界控制來做到這一點不起作用。如何製作圓形拐角wpf表格

我的問題是,我想我的應用程序與圓角形的角落。我用usercontrol做到了這一點,但無法用WPF中的主窗體做到這一點。

所以請告訴我我是如何做到這一點的。

這是我的xaml代碼。

<window....> 
<Grid> 
    <Border CornerRadius="10"> 
     <Grid> 
      ------------- 
     </Grid> 
    </Border> 
</Grid> 
</window> 

回答

1

您可以添加到邊框: BorderBrush = 「紅」了borderThickness = 「1」

帶圓角的邊框會出現。

<Border CornerRadius="10" BorderBrush="Red" BorderThickness="1"> 
    ...your code 
</Border> 
+0

我也這樣做,但主要形式沒有影響。仍然是矩形的shap。 –

+0

你是什麼意思「主要形式」?你的屏幕放置在Windows框架上? – Cyferka

+0

完成。我得到了它謝謝 –

0

這應該適合你。

<Window ... 
     WindowStyle="None" 
     Background="Transparent"> 
<Border CornerRadius="10" 
     Background="White"> 
    <Grid> 
    </Grid> 
</Border> 
+0

完成。我明白了,謝謝 –

+0

我明白了。只需使用以下。 <窗口AllowsTransparency = 「真」 WindowStyle = 「無」 BACKGROUND = 「透明」> <邊框CornerRadius = 「10」 BorderBrush = 「紅」 了borderThickness = 「1」 背景= 「白」> - ------------

0

進入App.xaml中

<Application.Resources> 
    <Style TargetType="Whatever Kind of Button You Wand" x:Key="RoundedButtons"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="Whatever Button You have decided"> 
        <Grid> 
         <Border Margin="5" Padding="5" BorderThickness="1" BorderBrush="#d9d9d9" Background="#595959" CornerRadius="10"> 
         </Border> 
         <ContentPresenter HorizontalAlignment="Center" 
             VerticalAlignment="Center"/> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 

然後當你想這種風格應用到您的按鈕

<Button Style="{StaticResource RoundedButtons}"/>