wpf - How to 'merge' a XAML file and its code-behind with Visual Studio -


i have template defined in xaml file named 'mytemplate.xaml'. template using code-behind file named 'mytemplate.cs'.

mytemplate.xaml:

<resourcedictionary x:class="project.templates.mytemplate">     <datatemplate ... /> </resourcedictionary> 

mytemplate.cs:

namespace project.templates {     public partial class mytemplate : resourcedictionary     {         ...     } } 

in visual studio solution explorer, these 2 files side side. put these 2 files together, control , code-behind.

what have: enter image description here

what have: enter image description here

what best way that? thank you.

you need edit .csproj file. find <compile> element mytemplate.cs, , add <dependentupon> element under it:

<compile include="mytemplate.cs">   <dependentupon>mytemplate.xaml</dependentupon> </compile> 

see blog post: make project item child item of another


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -