question

Flithor-2893 avatar image
0 Votes"
Flithor-2893 asked RodAtWork answered

How to maintain two slightly different XAML for two projects?

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-wpf
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RodAtWork avatar image
0 Votes"
RodAtWork answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.