2015-06-23 30 views
3

我试图用一个user control支持,我已经尝试了一些不同的解决方案,但是,我一直没能解决这个问题:控制不为Windows Presentation Foundation(WPF)项目

在我的主窗口,我写的代码如下图所示:

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

...我已经寻找一个这个问题的解决方案,我相信我失去了一些非常简单的东西。

回答

5

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

<controls:WeekView></controls:WeekView> 
相关问题