Windows Presentation Foundation (WPF) 项目不支持控件

Controls is not Supported in the Windows Presentation Foundation (WPF) Project

我正在尝试使用 user control 并尝试了几种不同的解决方案,但我无法解决此问题:

在我的主 window 中,我编写了如下代码:

   <Window x:Class="WPF_Work_Timer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:WPF_Work_Timer"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TabControl>
            ...
            <TabItem Header="This Week">
                <controls.WeekView></controls.WeekView> 
                <!-- ^Controls is not supported in WPF Error is here. -->
            </TabItem>
            ...
        </TabControl>
    </Grid>
</Window>

我为 User Control:

编写了如下代码
 <UserControl x:Class="WPF_Work_Timer.WeekView"
             x:Name="WeekViewControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        ...
    </Grid>
</UserControl>

我已经搜索了这个问题的解决方案,我确信我遗漏了一些非常简单的东西。

问题是您使用的是句点 . 而不是冒号 :。试试这个:

<controls:WeekView></controls:WeekView>