Not able to reference to custom control in another dll (RC1)

Respondida Not able to reference to custom control in another dll (RC1)

  • martes, 12 de septiembre de 2006 20:07
     
     

     

     

    After installing RC1 I am not able to initialize custom controls created in another project even by using

    mlns:customControls="clr-namespace:XYF.Controls.WPF;assembly=XYF.Controls.WPF", although on I can add the same control via code behind but in Xmal it pukes.

    Also in the xaml if I am creating a name of panel using name="XYX" I am not able to reference them in code behind.

    Any ideas why it is happening.

    Thanks

    Atul

Todas las respuestas

  • martes, 12 de septiembre de 2006 20:24
    Moderador
     
     

    I'm investigating a similar issue now.

    Is your XAML file "Loose XAML" or compiled XAML?

     

    If it is loose, there are 2 things to try:

    1. make sure the assembly is loaded before the xaml loads.
    2. add the fully qualified name (strong name) to the end of "...WPF"

    If it is compiled:

    1. make sure you have a reference to the XYF.Controls.WPF

    Thx, Rob Relyea
    http://rrelyea.spaces.live.com

  • martes, 12 de septiembre de 2006 21:39
     
     

     

    I am having both loose as well as compiled controls(one is based on color picker from WPF examples)

    The reason why I am posting is that the assembly is loaded as I can reference them after InitializeComponent()

    but Xaml editor complains.

    I am able to get away this issue by adding that control through code behind but now I cannot even get to the parent control after changing the name(or not able to reference the hosting control by name).

    I have very clearly marked the reference on top of wpf page hosting the control using both

    xmlns:UserControl="clr-namespace:XYZ.Controls.WPF;assembly=XYZ.Controls.WPF"

    Atul

  • martes, 12 de septiembre de 2006 23:17
     
     
    Wait, can you compile the project, or is it just the editor that's saying that things can't be found?  The editor hasn't been able to properly resolve types out of the generic xaml namespaces as far as I can remember, so it underlines them and says that they aren't found, but it should still compile just fine.

    Also you can't reference XAML names in code-behind until you've compiled the XAML at least once.
  • miércoles, 13 de septiembre de 2006 11:11
     
     
    When specifying a name for custom UI elements in XAML, please use x:Name="MyCustomControl" instead of Name="MyCustomControl".

    Sheva
  • sábado, 16 de septiembre de 2006 4:47
     
     

     

    I will try the x:name while referencing the customcontrol.

    Atul

  • miércoles, 20 de septiembre de 2006 14:18
    Moderador
     
     Respondida

    To explain a little bit about why x:Name is needed in some circumstances, as others will hit this.

     

    When you are using a locally defined component in xaml (another type that is defined in the same assembly that is being built) via the clr-namespace xmlns uri without an "assembly=" clause, we use 2 different passes to do markupcompilation.

    In the first pass, the assembly hasn't been built yet, so the markup compiler doesn't know the different between "Name" "Click" and "Background".  Are they properties, events, or the name property?  The markup compile has no idea.

    It is at this step when the .g.cs or .g.vb file is generated...and in order to generate a field for a control, you need to explicitly use x:Name, instead of Name.  This helps the markup compiler understand this situation.

     

    In the future, we hope for better communication/cooperation between the xaml markup compiler and language compilers...that would make the "x:Name" use unnecessary.

    Thanks, Rob Relyea
    Program Manager, WPF Team
    http://rrelyea.spaces.live.com