2014-02-26 47 views
0

所以我有一個WPF用戶控件,我試圖以「實例」 /調用一個在MenuVsHorsLigne.XAML用戶控件沒有裝配

用戶控件是通過的UserInterface添加一個新的做右鍵單擊創建元素我選擇了WPF中的UserControl。 (IE MapDisplay.XAML)

這裏是我的項目的框架:

GamingClient

  • 文件夾|資產
  • 文件夾|聊天
  • 文件夾| GameEngine
  • 文件夾|地圖
  • 文件夾| UserInterface

的UserInterface

  • MenuVsHorsLigne.xaml
  • MapDisplay.xaml

這裏是我的MapDisplay.xaml代碼:

<UserControl x:Class="GamingClient.UserInterface.MapDisplay" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <Border BorderBrush="#a197ff" BorderThickness="1" Margin="5 5"> 
     <Grid> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="1*" /> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="1*" /> 
       <ColumnDefinition Width="10*" /> 
       <ColumnDefinition Width="1*" /> 
      </Grid.ColumnDefinitions> 

      <Image MaxHeight="64" Source="/GamingClient;component/Assets/next.png" Grid.Column="2"/> 
      <Image MaxHeight="64" Source="/GamingClient;component/Assets/prev.png" Grid.Column="0"/> 

      <Grid Grid.Column="1"> 
       <Grid.RowDefinitions> 
        <RowDefinition Height="1*" /> 
       </Grid.RowDefinitions> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="3*" /> 
        <ColumnDefinition Width="7*" /> 
       </Grid.ColumnDefinitions> 

       <Image MaxHeight="215" MaxWidth="215" HorizontalAlignment="Center" Margin="5 0" Source="/Maps/1.jpg"/> 
       <Grid Grid.Column="1"> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="1*" /> 
         <RowDefinition Height="4*" /> 
        </Grid.RowDefinitions> 

        <ComboBox Name="comboBoxMapsName" VerticalAlignment="Center" HorizontalAlignment="Left" MaxWidth="200" Margin="5 0" Grid.Row="0"/> 
        <TextBlock FontStyle="Italic" Foreground="White" Text="Description de la carte par l'auteur qui n'apporte aucune information pertinente aux yeux du joueur ou de son adversaire qui lui est aussi pourri que l'hôte." TextWrapping="Wrap" Margin="10 5 5 5" Grid.Row="1"/> 
       </Grid> 
      </Grid> 

     </Grid> 
    </Border> 
</UserControl> 

這是我MenuVsHorsLigne。 xaml ///刪除了alo這就是東西的T已經在這個問題

<Window x:Class="GamingClient.UserInterface.MenuVsHorsLigne" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MenuVsHorsLigne" Height="559" MinHeight="350" Width="633" MinWidth="600" 
     Closed="Window_Closed" 
     IsVisibleChanged="Window_IsVisibleChanged" 
     xmlns:custom="GamingClient.UserInterface"> 
    <Grid> 
     <custom:MapDisplay Grid.Row="0" Grid.Column ="0"></custom:MapDisplay> 
    </Grid> 
</Window> 

問題是,VS2010不會在XAML命名空間找到MapDisplay ....沒有部分被跟隨各種教程,並試圖找到類似的問題...我的代碼似乎好,所以我對於MapDisplay「invisibile」的內容沒有任何想法。

這裏是MapDisplay.xaml

使用該註冊命名空間
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 

namespace GamingClient.UserInterface 
{ 
    /// <summary> 
    /// Interaction logic for MapDisplay.xaml 
    /// </summary> 
    public partial class MapDisplay : UserControl 
    { 
     public MapDisplay() 
     { 
      InitializeComponent(); 
     } 
    } 
} 
+0

只是想知道...在你的代碼隱藏(類的.cs部分),是否定義爲公共? – DRapp

+0

它的公開和部分默認設置(根本沒有碰到.cs) – Fawar

+0

在問題中添加了代碼。它真的讓我煩惱:O – Fawar

回答

0

嘗試的代碼的.cs

xmlns:custom="clr-namespace:GamingClient.UserInterface" 
+0

沒有工作要麼...同樣的錯誤:S – Fawar

+0

其實它在2013年的工作,但它不在2010年 – Fawar

相關問題