How to maintain two slightly different XAML for two projects?

Flithor 196 Reputation points

I have two projects in my hands that are used in different scenarios.

There are many XAML pages in these two projects, and some of page in one project is copied from another project(old version) and modified namespace, added some new things.

Now I am responsible for both projects, but I find it very difficult to maintain the both projects, so I am trying to refactor.

What can be confirmed is:

  1. Part of the pages is copied from the old project code (namespace modified, but the version is backward).
  2. Part of the pages was copied in recently, but there are some changes.

Once I need to fix or add something, I have to modify these two projects, and also need to pay attention to the problems caused by the difference in code between the two projects, I can't copy file simlpely. Which is too painful.

What I want to do is to extract the same xaml and backcode part between the two projects for unified maintenance, but at the same time compatible with the difference part (such as different columns of the DataGrid, different query, different color theme, etc.)

What should I do? Any suggestion?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,710 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rod At Work 866 Reputation points

    I don't know if this will address what you're asking for or not, but you might consider creating a project template to use for when you need to create a new project with the same, basic types. I will give the caveat that I've tried to do this, but it wasn't successful.

    Where I work we're trying to replace several small apps originally written in MS Access, with some WPF apps. However, our approach, which I don't recommend, has been write a general purpose WPF app that we have stored in TFS. Then when we need to create a new app, to replace one of those Access apps, we fork the main branch into another branch for the new app. (Note: we never merge the forked branch back to the main branch.) What this results in is lots of Visual Studio solutions that appear in the most recently used list, all named the same thing. Very confusing; the odds of opening the wrong solution are high. (Although the guy who came up with this idea is pleased as punch about his idea and he claims to have no problems with it. Meanwhile the rest of us have to suffer through.) What I have done, whenever I've had to start a new project based upon on main, basic project, is take a day to go through the code and rename the namespace in every place it appears. At least that way it will look different when I open VS.

    This is the reason why I've considered trying to implement project templates. I think that the idea of project templates is sound. But so far the documentation on how to do this is sparse. I've not seen a course on Pluralsight nor LinkedIn Learning on Visual Studio project templates, so you're on your own.

    0 comments No comments