XAML and Assembly References Problems

General Overview

My solution contains 2 Projects

  • RichClient, Namespace test.gui.definition
    This project will only contain an App.xaml
    LibraryProject is type of Windows Application (WPF)
  • GUIDefinition
    Project ist type of Class
    • Folder: UserControls (Namespace test.gui.definition.usercontrols)
      This folder contains customized UserControls
    • Folder: Pages (Namespace test.gui.definition.pages)
      This folder contains Pages to display the UserControls and to handle the navigation

Problem 01

How can I start a Page in Project GUIDefinition Pages/Login.xaml from the App.xaml in RichClient

Problem 02

How can I import a UserControl GUIDefinition/UserControls/LoginControl.xaml in a Page GUIDefinition/Pages/Login.xaml

xmlns:guidefinition="clr-namespace: ;assembly= "

I hope that someone could help me. Sorry my terrible English, but I'm excused, I'm from Switzerland. Thank you for reading my problem and propably for your answer.

Manuel Bauer




Answer this question

XAML and Assembly References Problems

  • K.V.Bharath

    Hi Dennis

    Thank you for your short and exact answer. Problem 01 worked after the first build.

    Problem 02 did not work like you said.

    I think, the problem is, that all user controls are in a subfolder /UserControls or that the pages referring the user controls are in the same assembly. The compiler does not find my .xaml files (e.g. LoginControl.xaml).

    "Error 2 The tag 'LoginControl' does not exist in XML namespace 'clr-namespace:test.gui.definition.usercontrols;assembly=GUIDefinition'."

    Do you think that it is posssible to do it like that

     

    Manuel



  • Zero WangXin

    Hi Dennis

    Thank you for your problem-solving answer. It really worked like this. Less is more, right

    Manuel



  • Madmax71

    Hi Manuel, try this:

    1. Add a reference to your external GUIDefinitaion assembly from the RichClient project and set Application.StartupUri to point to the page in that external assembly using a pack URI. In your scenario use "pack://application:,,,/GUIDefinitaion;component/Pages/Login.xaml".

      More information on pack:// URIs at http://msdn2.microsoft.com/en-us/library/aa970069.aspx

    2. You can also reference types in different namespace from a another assembly like this:

      <guidefinition:MyType xmlns:guidefinition="clr-namespace:test.gui.definition.usercontrols;assembly=GUIDefinition"/>


  • Blast

    Yes, remove the 'assembly=GUIDefinition' part to reference a UserControl defined within the same assembly  as the Page: 

        <guidefinition:MyType xmlns:guidefinition="clr-namespace:test.gui.definition.usercontrols"/>

     



  • XAML and Assembly References Problems