How to manually reload the Visual Studio designer for WPF

前端 未结 9 1717
广开言路
广开言路 2020-12-23 13:17

Is there any way to force the WPF designer to reload or refresh, without rebuilding the entire project or solution?

If there\'s an error, I get an option in the desi

相关标签:
9条回答
  • 2020-12-23 13:55

    I'm a little late but this is the best solution1 I've found so far: whenever the designer does stupid stuff, I just kill it's process.

    Press Ctrl+Shift+Esc
    Navigate to the Processes tab.
    Kill XDesProc.exe

    This also fixes issues for the properties window (like when it gets jammed and you can't type stuff into it).

    1 This is a solution for designer issues. Your issues may also be caused by compilation problems, in which case just right click on the solution in the solution explorer, and clean it. The reason behind it is that sometimes the compilation loses synchronicity with the generated files from XAML, and cleaning the solution just deletes those intermediate files; it's like a reset so your compilation can start off with a clean slate.


    To do it fast:

    Comfortably it's usually the last one if sorted alphabetically.
    When it is, it's almost like a ritual for me to quickly pop up the task manager, click any process, press End, Delete, Enter (done), Esc (exit task manager). Instead of restarting VS and waiting for all the loads & unloads, you can do that in 1-2 seconds.

    0 讨论(0)
  • 2020-12-23 13:55

    I'm not sure how this works in WPF editing, but with ASP.NET pages when the design view wont update i can do 2 things

    1. Exit Visual Studio and restart
    2. Go into source view (not split), type something and remove it (not by undoing, just delete or backspare) and save it. Then return to design view, usually the view has been updated then.
    0 讨论(0)
  • 2020-12-23 14:09

    The Visual Studio designer attempts to keep the rendered view in sync with the XAML. That's the advertised behavior.

    • The first thing you should check is that there are no errors in the errors window. It may be something as simple as a missing angle bracket.
    • The second thing to check is whether you have any code (other than your code-behind) which needs to be compiled for the designer to render your XAML correctly. This includes any of your own datatypes that you instantiate in XAML, any custom controls you have written (e.g. MyTextBlock derived from TextBlock), or any classes directly or indirectly in support of design-time data. If so, you need to rebuild your project.
    • The last thing to check for is possible bugs in the designer. In spite of the advertised behavior, the designer may get out-of-sync due to bugs. In that close, close the XAML window and re-open it. Other tricks that might work are selecting the XAML tab and then the Design tab, or maximizing the XAML pane.

    As far as rebuilding your application goes, you don't need to do this as a habit. You only need to recompile it when the above conditions apply. Once they don't apply, you can just edit the XAML. Another way to say this is that if you haven't modified code, you shouldn't need to rebuild (modulo bugs).

    0 讨论(0)
提交回复
热议问题