2013-10-23 31 views
0

我想打開一個TabControlTabItem中的用戶控件。在tabcontrol的tabitem中顯示UserControl

我這樣做的:

<Window x:Class="MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:a="clr-namespace:Pauspan_WPF_" 
    Title="Pauspan" Height="568" Width="1095" Name="FrmMain"> 
    <Grid Name="MainGrid"> 
    <TabControl Height="400" Margin="187,33,16,0" Name="TbCtrlMain" > 
     <TabItem Header="TabItem1" Name="TabItem1"> 
      <a:UserControl1 /> 
     </TabItem> 
    </TabControl> 

,但它提供了有關該行的錯誤:

<a:usercontrol1/> 

的錯誤是:

**The type 'a:UserControl1' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.** 

的UserControl1的名稱的UserControl。

我該怎麼做?爲什麼會出現這個錯誤?

+0

http://www.codeproject.com/Articles/32825/How-to-Creating-a-WPF-User-Control-using-it-in-aW –

+0

你肯定的UserControl1是Pauspan_WPF_命名空間相同的程序集? – Nitin

+0

我不知道如何檢查它?或如何添加它在組裝? – user2689704

回答

1

我正在使用Visual Studio 2010,雖然設計師抱怨並顯示錯誤,但它仍然允許我編譯該項目。我剛離開我的xaml中的「; assembly = ....」位。

<Window x:Class="SafeDrivingCertificate.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:rt="clr-namespace:SafeDrivingCertificate" 
     Title="MainWindow" Height="350" Width="525"> 
    <Grid> 
     <TabControl HorizontalAlignment="Stretch" Name="tc" VerticalAlignment="Stretch"> 
      <TabItem Header="Review Coming Due" Name="tbReview"> 
       <rt:ReviewTab /> 
      </TabItem> 
     </TabControl> 
    </Grid> 
</Window> 
相關問題