I have XAML file say SomePage.xaml
.
I was making a mistake by refactored it's code behind class from SomePage
to CardsPage
class.
Now XAML file doesn't link with the code behind anymore.
How to link these files together again?
If you open the project file that includes your CardsPage, you can link them back together again.
You should have 2 sections in there, one should be like this:
<Page Include="CardsPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
The other section should look like this:
<Compile Include="CardsPage.xaml.cs">
<DependentUpon>CardsPage.xaml</DependentUpon>
</Compile>
The DependentUpon is important, it will nest the file in the IDE below the xaml.
Note: In your screenshot, the CardsPage looks like it was renamed to CardsPage.cs, I would make sure that you rename it back to CardsPage.xaml.cs.
Hope that helps, I sadly don't know any other way than fiddling in the project file to make it work again.
I have some problems when I refactor the code behind with the XAML(renaming for example) and I find a small extension to "relink" files together.
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.FileNesting
It's easier than modifying the csproj and less dangerous.
See Example Below
Step 1
Step 2
[
Result
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With