How to manually reload the Visual Studio designer for WPF

WpfVisual StudioXamlDesigner

Wpf Problem Overview


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 designer view to refresh the designer. But if I don't have an error, how can I get the designer to refresh after I've made a change?

Wpf Solutions


Solution 1 - Wpf

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.

Solution 2 - Wpf

You can add this to the Tools menu in Visual Studio.

Once configured, use Tools..XAML Designer Restart:

Alt+T then L

enter image description here

enter image description here

I tried configuring it for Alt+T then X but this clashed with Tools..Choose ToolboX Items.

Update

These days, I prefer to just hit Ctrl+Shift+Esc to bring up the process manager, then X to skip to XDesProc.exe then Delete to kill the rogue process(es).

Solution 3 - Wpf

In newer versions of Visual Studio there is an icon on the bottom of the designer to "Disable Project code". If you toggle this off and on it will reload the designer.

Solution 4 - Wpf

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).

Solution 5 - Wpf

I'm not sure, but I think a build will refresh your view in that situation.

Solution 6 - Wpf

There is any event handled in that XAML file, then mostly it will not display the design preview from Visual Studio. If you want to see the design from Visual Studio, try with Command Binding instead of event, you will see the preview.

Solution 7 - Wpf

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.

Solution 8 - Wpf

When you add a new row of code or a new object, XAML designer is sync but I encountered non-sync behavior when a property of an object is changed.

A tricky way is that when you change a property you only need to remove a ">" character from end of an instruction then retype it.

Solution 9 - Wpf

On the toolbar in the XAML designer, choose the "Disable project code" button to reload the designer link which stays on the right side of "Turn on snapping to snaplines".

Disable project code in the designer

If it is disabled, you can try to check the configuration manager and change processors to "Any CPU".

For projects that target ARM or X64 processors, Visual Studio cannot run project code in the designer, so the Disable project code button is disabled in the designer. Check this:

Debug or disable project code in XAML Designer

Solution 10 - Wpf

For information, I had the same issue with the XAML Designer of Visual Studio Community 2017, i.e. sometimes the designer doesn't show anything, the easiest solution is then to close the XAML file and reopen it.

I also frequently get the exception "An Unhandled Exception has occurred - Click here to reload the designer - Details: The XAML Designer has exited unexpectedly" (the click restarts the designer successfully).

Note that, in this VS version, the process of the XAML designer is not named XDesProc.exe, but UwpSurface.exe. If you prefer or have to kill the process, then the designer shows the same exception as above, and you may restart it.

Solution 11 - Wpf

use process hacker and kill the WpfSurface process (blend only)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondthrasherView Question on Stackoverflow
Solution 1 - WpfMasterMasticView Answer on Stackoverflow
Solution 2 - WpfContangoView Answer on Stackoverflow
Solution 3 - WpfAleksandr AlbertView Answer on Stackoverflow
Solution 4 - WpfRick SladkeyView Answer on Stackoverflow
Solution 5 - Wpfuser348905View Answer on Stackoverflow
Solution 6 - Wpfrcube9View Answer on Stackoverflow
Solution 7 - WpfRonaldView Answer on Stackoverflow
Solution 8 - Wpfm.eslahi.kView Answer on Stackoverflow
Solution 9 - WpfStevenZView Answer on Stackoverflow
Solution 10 - WpfSandra RossiView Answer on Stackoverflow
Solution 11 - WpfWhomanView Answer on Stackoverflow