none
WPF Composite and Custom Contols RRS feed

  • Question

  • Can WPF composite controls be created using XAML and C# in a separate assembly/DLL as can be done for Windows Forms controls? Any tips? Thank You.
    Monday, July 16, 2007 1:40 PM

Answers

  • Yes, you can create composite controls in another library. All you need to do to use them is to import the namespace in the xaml page where you want to use the control.

     

    Example:

    Code Snippet
    xmlns:src
    ="clr-namespace:Test.UI.Controls.MyControl;assembly=Test.UI.Controls"

     

     

    then just use the control you created which is named "Clock"

     

    Code Snippet

    <src:Clock />

     

    Monday, July 16, 2007 5:17 PM

All replies

  • Yes, you can create composite controls in another library. All you need to do to use them is to import the namespace in the xaml page where you want to use the control.

     

    Example:

    Code Snippet
    xmlns:src
    ="clr-namespace:Test.UI.Controls.MyControl;assembly=Test.UI.Controls"

     

     

    then just use the control you created which is named "Clock"

     

    Code Snippet

    <src:Clock />

     

    Monday, July 16, 2007 5:17 PM
  • Thank you. Also, I would think the control itself can be authored using XAML since it creates a DLL like any other language?
    Monday, July 16, 2007 9:39 PM
  • Correct.
    Tuesday, July 17, 2007 4:58 PM
  • But then you cannot inherit from them because of the XAML definition in the base class... correct?
    Tuesday, July 17, 2007 7:35 PM
  • I think inherticance works with XAML as with any other language. Inheritance in .NET does not require header files for class definitions as C++ does. Rather the class metadata comes from the assembly. .Net is designed to be language neutral. The powerful implications of this become evident when we consider that even XAML is resuable through .NET.

    http://msdn2.microsoft.com/en-us/library/xcd8txaw.aspx

     

     

    Wednesday, July 18, 2007 3:08 AM