繁体   English   中英

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

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

我试图使用user control ,我尝试了一些不同的解决方案,但是,我无法解决这个问题:

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

   <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> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM