Open ghost1372 opened 1 year ago
The code behind file does not seem to be generated, can't you just add a Generic.xaml.cs that has the required content?
Generic file is generated by your tool, how i can add a code-behind for this?
What do you think about this Idea, if we consider a property for example IsCodeBehind
<XAMLCombineItems Include="Themes\ItemTemplate.xaml">
<TargetFile>Themes\Generic.xaml</TargetFile>
<Visible>True</Visible>
<IsCodeBehind>True</IsCodeBehind>
</XAMLCombineItems>
Then, instead of the contents of this dictionary being placed inside the generic, We only have one reference to this dictionary
in Generic.xaml-->
<theme:ItemItemplate/>
The Generic.xaml is generated by my tool, but it doesn't know or care about any code files. If you just create a Generic.xaml.cs at the same directory the compiler should just pick it up, as my tool runs before the compiler does.
So how about x:class attribute? Does this attribute added to generic.xaml by tool?
All attributes/namespaces are taken over to the generated file. There might only be one issue with your x:class. If you have multiple source files with x:class, but a different value for each that won't work.
Have you tried just adding a Generic.xaml.cs for your case?
I will test as soon as I get home But I guess it won't work because the x:class (mynamespace.folder.itemtemplate) in itemtemplate.xaml is connected to itemtemplate.cs codebehind If i create a generic.cs file how exactly will the x:class be connected to the generic.cs file? I am confused a little
You could try copying your existing file and just rename it to Generic.xaml.cs. That might work. I have to admit that i haven't done any WinUI development so far. So it's just guessing from my WPF experience.
Ok tnx i should test, Do you have any comment about my idea? Adding a property in xamlcombineitem csproj? I think this can be work
hi, i have a Library and in this library i have a ResourcesDictionary file called
ItemTemplate.xaml
in this file i have aDataTemplate
, for using x:Bind method i have to set an empty Code-Behind for this ResourcesDictionary. when i compile my library with merging this ResourcesDictionary into Generic.xaml file and running an example project, i get some exceptions. is this supported? if not can you please add it?https://github.com/WinUICommunity/LandingsPage/blob/main/LandingsPage/Themes/ItemTemplates.xaml
https://github.com/WinUICommunity/LandingsPage/blob/main/LandingsPage/Themes/ItemTemplates.xaml.cs