Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create a class in WPF as this (i.e solution explorer -> add newitem -> code -> class). Now how to i add this class into XAML file?
Posted
Comments
Pandya Anil 24-Nov-11 8:26am    
waht is your question ? how can someone add class file to XAML file, both are separete entities... and are meant to be separete...
Wayne Gaylard 24-Nov-11 9:07am    
What if the class is a converter, or a collection that can be used for binding. Of course you can add a class as a resource in a XAML file.

1 solution

You can reference your class in a XAML file by creating a reference to the namespace of your class and then including this as a resource . Something like this:-

XML
<!--Declare Namespace-->
       xmlns:yourNameSpace="yourNameSpace Here">
   <Window.Resources>
       <!--Add to resources-->
       <yourNameSpace:yourClassHere x:Key="yourClas"/>
   </Window.Resources>


Hope this helps
 
Share this answer
 
Comments
Uday P.Singh 24-Nov-11 11:01am    
Agree 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900