Visual Studio 2010 - XAML Editor Extraordinarily Slow - wpf

Has anyone else experience incredibly slow performance in the XAML editor in VS 2010? If I have a new project with a limited number of files, the performance is fine. However, if I have a project with a larger number of XAML files, the XAML editor hangs intermittently every few seconds, making it almost impossible to use.
I should also note that the performance is only slow in one particular project where I am referencing DevExpress 2010. I am not certain if this is related.
Any suggestions on solutions to this problem would be greatly appreciated.
Chris

In Visual Studio 2012:
Go to
Tools > Options > TextEditor > XAML > Misc
Check Always open documents in XAML view and uncheck Automatically populate toolbox items.
In Visual Studio 2015, 2017:
Go to
Tools > Options > XAML Designer
uncheck Automatically populate toolbox items.
This fixed my same problem.

If you don't need the visual designer, you can select a different editor in visual studio:
Right click the xaml file -> Open With... -> Source Code (Text) Editor
You will only lose the split view, intellisense etc. should still work.
If you need to check something in the designer you can still click 'view designer' to open the normal XAML editor again.
If you want to improve the performance of the visual designer, try checking DesignerProperties.GetIsInDesignMode in your code-behind. The visualiser instantiates your controls to know how to display them, thus executing parts of the code-behind.

Like the OP, I had extreme lag in the xaml editor on a project that relied heavily on DevExpress WPF controls. After trying unsuccessfully to resolve this issue with the other solutions posted here, I eventually tried deleting my Solution User Options (.suo) file, which is usually located in the same folder as the solution (.sln) file. This immediately resolved the issue. You may want to read this post about what visual studio stores in the suo file so you can reset anything important (such as build configuration - mine always defaults the active solution platform back to "Mixed Platforms" for example)

Short answer: if you do not use designer much, just replace the default editor for XAML, thus getting rid of XAML visual designer and speeding things up. Right click any XAML file, click Open with... and choose another default editor. Source code (text) editor works just fine.
Now it should be already fine. If you want to understand the details and completely get rid of the slow designer, read the long answer.
Long answer: Here is a nice explanation of what happens and why is it that slow.
A brief todo based on the aforementioned article in order to completely disable the visual designer of XAML:
Under Tools->Options->Text Editor->XAML->Miscellaneous->Default View check Always open documents in full XAML view
Open Task manager and end XAML Designer process XDesProc.exe (Note: for VS2013 right click this process and go to containing folder. Rename the exe to sth else, than end the process)
Standard XAML editor will load this process again (I guess it will not succeed with VS2013 and actions done in P.2). However, right click any XAML file, Open with... and choose another default editor. Source code (text) editor works just fine.

While using dev express, I've noticed some laggy response in the Visual Studio designer. This appears to be due to the license authentication of the DevExpress products.
If you delete the "Licenses.Licx" file (found in the project properties folder) you'll notice a marked improvement in performance.
Note: Removing the license file doesn't stop you from using DevExpress controls. But it does stop VS from constantly authenticating it.

Related

Simple ControlTemplate (edit a copy) for WPF Window doesn't work in Blend for Visual Studio 2017

Goal: Edit the ControlTemplate of a Window to remove the caption buttons via Blend (Close/Minimize/Maximize). Why? Need a window with a title bar (draggable) that can't be closed/minimized/resized. It's a temporary status window that pops up, etc. (I've seen solutions that go into the Win32 APIs, and wonder why. This should be doable via Blend!)
Anyway... Blend for Visual Studio 2017 seems to be OK with my attempt. At least initially.
Click "[Window]" in the Document outline and then select "Edit Template => Edit a copy"
Blend complies and gives me this control template.
However, immediately the XAML is flagged as having errors.
I figured "well, maybe this is just a designer issue. Maybe it will build." Nope.
"The type reference cannot find a public type named 'WindowInstance'.
"The name 'WindowInstance' does not exist in the namespace
'clr-namespace:Microsoft.VisualStudio.DesignTools.WpfDesigner.InstanceBuilders;assembly=Microsoft.VisualStudio.DesignTools.WpfDesigner"
Well, I've looked for "Microsoft.VisualStudio.DesignTools.WpfDesigner" on both NuGet and in the install folders and it doesn't seem to be there.
I've also read this solution, which mentions adding "Blend for Visual Studio SDK for .NET" in the Visual Studio 2017 installer under the "Individual Components" page. I've done that. Still I have the error.
I'm uncertain where Blend got the initial ControlTemplate from in the first place if it doesn't resolve to an assembly on my machine.
Regarding the actual solution... what I'm doing now is faking a window with a title bar (that has no buttons) and using the system brushes to make it look like a window with a title bar--but that isn't draggable... which is another problem to solve.
Really, why I can't do something as trivial as removing control buttons from a window is beyond me. I suppose there are philosophical reasons to not allow people to remove the close button on a window, but that shouldn't be some arbitrary call that a dev at Microsoft gets to make for me or anyone on my team.
Thank you for your assistance.
Chad.

Visual Studio 2013 Extremely Slow at Saving Files

I have a WPF project where it sometimes takes extremely long time to save a module.
(I see the little saving floppy pulsating "forever" and nothing happens for several minutes).
Often I have to use the Task Manager to end Visual Studio and then start over again.
The first couple of times after restart, saving is pretty quick, but then it takes forever again.
Any hints to solve this problem would be very much appreciated.
Problem fixed in Tools->Options->Source Control, by setting the source control plug-in to "None", which is fine as we are not using TFS or Git for the project. Not sure why this works, but Visual Studio does not "hang" after this change.
Here are some steps you can follow to increase the performance
Go to a xaml file via solution explorer. Right click open with..Choose Source Code (Text) Editor and Set as default.
Sample
Go to Tools > Options > Text Editor > XAML > Miscellaneous and check the check box "Always open documents in full XAML view".
Sample

VS 2012 hangs on loading XAML designer

We do MVVM and use DI in our WPF project. Now we are working on VS 2012. Whenever we open the views (XAML forms) the XAML designer shows the loading message. Then whenever we try to change the XAML code panel VS hangs (While it is froze on loading message). XDesProc.exe takes about 13% of CPU (As I have 8 cores so it takes 100% of a core). When I close it, VS goes out of halt. But if you change the XAML code the scenario will be repeated again.
We didn't have any problem with VS 2010 in the same situation.
What is wrong?
A work-around is described in this thread:
Visual Studio 2012 hangs on editing XAML
To summarise you can make VS not use the XAML designer, and just use the regular source editor:
Right-click on a XAML file in the Solution Explorer
Select "Open With..."
Select "Source Code (Text) Editor"
Click on "Set as Default"
Click OK
You're done!
I have the same issue on one of my views. It is not really a solution but i noticed that, when I comment out the DataContext Property, the cpu load is gone.
Open Xaml file (cpu load is rising)
Comment out DataContext property with viewmodel binding
Kill XDescProc.exe in TaskManager
Reload Designer (no cpu load)
Try installing the latest update to Visual Studio Update 1. If after the update it still occurs submit the issue to Microsoft Connect.
Make sure you that, if you have any code in the constructor or any other code that might execute in the designer, you detect the design mode and do not execute that code.
You might be connecting to a data source and the designer might be choking on that.
See: Is there a way to check if WPF is currently executing in design mode or not?
Our computer's VS2012 has updated to Update 4, but it is still hangs on loading XAML designer..

How to manually reload the Visual Studio designer for WPF

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?
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.
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.
You can add this to the Tools menu in Visual Studio.
Once configured, use Tools..XAML Designer Restart:
Alt+T then L
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).
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).
I'm not sure, but I think a build will refresh your view in that situation.
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.
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
Exit Visual Studio and restart
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.
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.
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
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.
use process hacker and kill the WpfSurface process (blend only)
Update for designer refresh/reload Visual Studio 2022 Xamarin, taskkill /IM java.exe

Is there a way to switch off wpf design surface in Visual Studio 2008?

I would like to know if there is a way to simply turn of the WPF design surface in Visual Studio 2008. I would like to have the xaml editor, but not the design surface as it slows down the IDE, when I try to open a XAML file. For my workflow having only the source files for xaml would be a better fit as I am doing all visuals in Blend.
Tools->Text Editor->XAML->Miscellaneous uncheck Always open documents in full XAML view
alt text http://www.dolittle.com/blogs/einar/WindowsLiveWriter/DisableXAMLdesignerinVisualStudio2008_118F4/image_2.png
The comment below informs of a catch when using this checkbox, that is it only affects files that have not been opened before. A solution from the link to the Microsoft Connect issue in the comment states that
If you really wish to reset the
open/close behavior for all XAML files
in your project, you can achieve this
by closing Visual Studio, then
locating the SUO file adjacent to your
SLN file and deleting or renaming it,
then re-opening Visual Studio. When
you re-open your solution an new SUO
will be created and all files will be
treated as "new". Please note this
will also remove any other
solution-specific IDE behavior for
your solution.
You should be able to right-click the .xaml file and select "Open With..." then select "Source Code (Text) Editor" (optionally clicking "Set as Default" to make it the default). This will open the file in the plain XML editor (you still get syntax highlighting and IntelliSense, too).

Resources