【发布时间】:2016-02-11 07:18:52
【问题描述】:
我创建 WPF 应用程序。我想创建无边框窗口。为此,我的代码如下
<Window x:Class="AzLeks.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode="CanMinimize" Height="600.586" Width="826.694" WindowStyle="None" AllowsTransparency="False"
MouseLeftButtonDown="MainWindow_OnMouseLeftButtonDown" Loaded="Window_Loaded"
WindowStartupLocation="CenterScreen">
<!--<Window.Background>
<ImageBrush ImageSource="images/bckgr.png" />
</Window.Background>-->
<Window.Resources>
<Style x:Key="Close" TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid Margin="-9,-13,-9,-16" HorizontalAlignment="Center" Background="Transparent" VerticalAlignment="Center" Height="630" Width="845">
<Grid.RowDefinitions>
<RowDefinition Height="235*" />
<RowDefinition />
</Grid.RowDefinitions>
<Border CornerRadius="12" BorderBrush="Transparent" BorderThickness="1" >
<Border.Background>
<ImageBrush ImageSource="/images/bckgr.png"></ImageBrush>
</Border.Background>
</Border>
<!--Some Content-->
</Grid>
【问题讨论】:
-
如果没有 xaml 代码,就很难弄清楚这里发生了什么。另外请确保在操作窗口的代码隐藏/C# 代码中没有发生任何事情。
-
@SteffenWinkler,我编辑我的问题。我没有任何操作窗口的 c# 代码。
-
您的窗口小于您的网格。你甚至会因为保证金而变得更糟。有一件事是肯定的,您在设计中看到的大小几乎与运行时不同。我会说在网格之前添加一个边框。不要给它任何余量,让您的 Windows 完全透明。您可以将背景添加到边框
-
@NawedNabiZada,但我想要窗口的cornerRadius。我怎么能用你的建议做到这一点?
-
@ElvinMammadov 检查我的答案。
标签: c# wpf cornerradius borderless