loginView.xaml代码是这样的
<Window x:Class="CourseManagement.loginView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CourseManagement"
mc:Ignorable="d"
Title="系统登录" Height="600" Width="360"
FontFamily="Microsoft YaHei" FontWeight="ExtraLight"
ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
WindowStyle="None" AllowsTransparency="True" Background="{x:Null}"
>
<Window.Resources >
<ControlTemplate TargetType="Button" x:Key=" CloseButtonTemplate">
<Border Background="Transparent">
<Path Data="M0 0 12 12M0 12 12 0" Stroke="White" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Center">
</Path>
</Border>
</ControlTemplate>
</Window.Resources>
<Border Margin="5" Background="White" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="Gray" ShadowDepth="0 " BlurRadius=" 0" Opacity=" 0.3" Direction=" 0">
</DropShadowEffect>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1.8*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Border Background="#007DFA" CornerRadius="10,10,0,0"/>
<Button VerticalAlignment="Top" HorizontalAlignment="Right" Width=" 50" Height=" 40"
Template="{StaticResource CloseButtonTemplate }">
</Button>
</Grid>
</Border>
</Window>
代码片
报错信息见下图
经过反复调试,最开始以为是.NET版本不对,后来仔细检查代码,发现是
<ControlTemplate TargetType="Button" x:Key=" CloseButtonTemplate">
CloseButtonTemplate前面多了一个空格。
真的是无语!!!