WPF window 外观与设计视图不一样
WPF window appearance is not same with design view
我创建了 WPF 应用程序。我想创建无边界 window。为此,我的代码如下
<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>
在设计模式下显示如下:
但是运行应用后显示为:
我不知道这里有什么问题。请帮助我,我找不到解决方案
类似这样。
<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" Width="820" WindowStyle="None" AllowsTransparency="True" Background="Transparent" MouseLeftButtonDown=" MainWindow_OnMouseLeftButtonDown" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">
<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>
<Border CornerRadius="12" BorderBrush="Transparent" BorderThickness="1" >
<Border.Background>
<ImageBrush ImageSource="/images/bckgr.png"></ImageBrush>
</Border.Background>
<Grid HorizontalAlignment="Center" Background="Transparent" VerticalAlignment="Center" >
<Grid.RowDefinitions>
<RowDefinition Height="235*" />
<RowDefinition />
</Grid.RowDefinitions>
<!--Some Content-->
</Grid>
</Border>
我创建了 WPF 应用程序。我想创建无边界 window。为此,我的代码如下
<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>
在设计模式下显示如下:
但是运行应用后显示为:
类似这样。
<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" Width="820" WindowStyle="None" AllowsTransparency="True" Background="Transparent" MouseLeftButtonDown=" MainWindow_OnMouseLeftButtonDown" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">
<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>
<Border CornerRadius="12" BorderBrush="Transparent" BorderThickness="1" >
<Border.Background>
<ImageBrush ImageSource="/images/bckgr.png"></ImageBrush>
</Border.Background>
<Grid HorizontalAlignment="Center" Background="Transparent" VerticalAlignment="Center" >
<Grid.RowDefinitions>
<RowDefinition Height="235*" />
<RowDefinition />
</Grid.RowDefinitions>
<!--Some Content-->
</Grid>
</Border>