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前面多了一个空格。
真的是无语!!!

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐