How to undo a "Reset Toolbox" in VS2008? - wpf

Is there any way to "un-Reset" the Toolbox in Visual Studio 2008?
I was trying to get my first-ever WPF UserControl to appear in the Toolbox. I rebuilt my project, then right-clicked on the Toolbox and chose "Reset Toolbox" from the pop-up menu; hoping that would "refresh" the control list (I know better now). Alas, the reset removed ALL the controls from the Toolbox for WPF projects (It's still OK for Win-Forms projects).
So is there a relatively quick way to restore all "the standard WPF controls" to the Toolbox?... I only had the standard controls (being a WPF noob) so "No" I didn't take a backup before I hit the reset switch... BIG Sigh!
Thanking you all in advance,
Keith.
EDIT: To document my (sort of) resolution to the problem...
I got my WPF controls back, but they're not in there nice seperate toolboxes (i.e. the expandable sections, or whatever you call them). Meh! It'll have to do ;-)
To get them back... With a WPF Window open (Window1.xaml for example): right-click on the General "toolbox", select "Choose items ..." from the pop-up menu, goto the "WPF Components" tab, select ALL items and click the checkbox of the last item (to make all tools visible), then click the OK button... then (if you want) right-click on the toolbox and select "Sort Items Alphabetically" then go back into right-click-Toolbox ~ Choose Items ~ WPF Components; and untick all those items which don't have distinctive icon (the "default icon" is a white window with a blue border containing a "cone" which appears to be blowing red bubbles... stoners beware?!?!). You'll probably have to OK your "unticks" half-way down the list, coz you can't scroll the toolbox (too see the icons) whilst the Choose Items dialogue is open.
Cheers all. Hope this helps the next MS Victim.
Keith.
PS: For what it's worth, I still think this is a "bug" in VS2008... Resetting the toolbars should retore them to there original condition. Which, as far as I'm concerned, includes the "out of the box" WPF toolbox configuration. I presume it's lost them coz the WPF Toolbox's where/are a "tack on"... implemented as "custom" toolboxs (the same as a user-defined toolbox). Sigh.
If it's still a "bug" in VS2010 then maybe it should be reported, so that atleast it (probably) won't be propagated to 2012, or whatever comes next.

Did you try running this command in VS2008 Command Prompt-
del "%LocalAppData%\Microsoft\VisualStudio\9.0\*.tbd"
Refer to this link - http://msmvps.com/blogs/coad/archive/2010/05/07/reset-the-visual-studio-toolbox.aspx
As per this it will re-populate the data.

It's probably a bit late now, but I find if I change environment settings etc and want to get them back I open a 2nd copy of Visual Studio before I close the other Visual Studio instance. Then close the one you changed and then immediately close the 2nd version.
This normally persists your settings from the last instance closed for next time opening.

Related

How do I open a WPF menu at design-time?

I'm styling a menu in WPF and would like to see how it looks, without having to launch the application to open the menu.
Is there a way to keep the menu open (so I can see the menu items) at design-time, so I can see the changes as I go?
I currently only have Visual Studio 2010 to work with.
You can set IsSubmenuOpen="True", but if you click somewhere else, menu will close. Set it again to open.
You should be able to see changes in the design window as soon as you make changes - are you using VS2010 express? I found that in express the designer didn't refresh when I made style changes - I had to close/re-open the form to see the changes reflected. You shouldn't need to build to see design changes unless of course you are adding new user controls etc that need to be built before the designer can process them

Visual Studio 2010 - XAML Editor Extraordinarily Slow

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.

Why is my WPF Events Tab gone?

I cannot see it any more in Visual Studio 2010. How can I do to get it back?
I have no addins as I just installed VS Studio.
Nevertheless this occurs on an existing solution with many projects inside. When I create a new WPF project from scratch the tab reappears.
It sounds like a piece of UI is missing from your Visual Studio display. Try the following to get it to show back up in it's original location
Tools -> Import / Export Settings
Select "Reset all settings" and hit Next
Save your current settings if you desire and hit Next
Pick the profile of your choice and hit "Finish"
Possible ways to fix:
Try remove all add-ins and
extensions.
Tools -> Import And Export Setting
-> Reset all settings
Repair Visual Studio installation.
It's not possible to give exact solution with such description of problem.
Your User Options file is broken.
To fix it, do the following:
Close Visual Studio
Go to the folder in which your .sln file reside
Delete the User Options file
Open the solution again
The Events tab is back!
Are you talking about the Properties Window? If the Properties Window is displayed, click on the yellow lightning bolt button towards the top. That will show you the events for the currently selected WPF element. If the Properties Window isn't open, press F4.
This is not a bug, but rather where the focus is set in your visual studio instance design view. From the design view click the window and then do properties (F4). This will enable the events to show and be set from the properties tag. Just make sure the focus is set on the proper item from which you want to set the events (dropdownlist, window, ect.). Hope this helps.
I clicked on the "Design" tab in the bottom and the "Lightning bolt" (Event tabs) reappeared, then it was still available after going into "Source" view mode.
Hope this helps someone.

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

Why do my toolbox items disappear in Visual Studio 2008?

I'm working on a solution that contains multiple projects targeting Windows Mobile 5 and standard Windows applications.
Lately when opening up a form in designer the common UI controls (textbox, button, label, etc etc...) have vanished leaving only the controls defined within the project.
Resetting the toolbox has no effect. A google search suggested deleting the toolbox temp files in the Local Settings\Application Data\Microsoft\VisualStudio\9.0, however this was only successful in bringing back the default controls for Windows Mobile 5. The WinForms controls are still mysteriously missing.
Also, if I right-click and Select All on the toolbox, all of the WinForms controls do in fact come up, however they're all grayed out.
Has anyone else experienced this?
I just had a similiar problem. In a managed C++ project all the default toolbox items disappeared form the winforms designer. After playing around for a while I found that there was a problem in the .vcproj file.
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="COLLADA Import"
ProjectGUID="{0DEEF9B6-1929-44E3-92EC-13712839FB63}"
RootNamespace="COLLADAImport"
Keyword="ManagedCProj"
TargetFrameworkVersion="0"
>
When you set TargetFrameworkVersion to a valid number, for example 131072 for .Net 2.0, the toolbox items will be back.
If you right click on the Toolbox and select 'Choose Items...' and then sort by the 'Namespace' column, you can then select the ones you need (for example System.Windows.Forms for WinForms).
You can multiselect with Shift and then select/deselect the group.
The controls then reappear in the Toolbox as enabled.
I've noticed this exact same thing for regular WinForms as well. I can't speak to mobile applications but in regular winforms this has a tendency to happen.
I believe it's actually a bug in Visual Studio.
There are some things you can do (again, for WinForms. I'm not sure about mobile) with adding attributes to your control. Such as:
[ToolboxBitmap(typeof(MyControl), "MyControlBitmap")]
There are some other useful related things on this site:
http://en.csharp-online.net/Design-Time_Integration-Attributes
I had exactly the same problem (after installing Windows Mobile SDK all items in the toolbox were greyed out).
I've startet the Visual Studio 2008 command line as administrator and started the following command (WARNING - all your settings are lost !!)
devenv /setup /resetuserdata /selfreg /resetskippkgs
After that the toolbox looked fine and worked like on the first day.
The idea came from this thread: connect.microsoft.com
Go to the Tools menu and choose import & export settings, then choose the 'reset all' setting, then yes. Save your current settings, after that you'll have your toolbox reappear.
Actually you may be able to add a registry key to get this to work also.
Make sure you're not in Debug mode.
If you are running Visual Studio 2008 under vista, try running it as an Administrator. Right click on the shortcut and select Run as Administrator.
Well guess what install Service pack 1 for VS 2008 and it would go away and if you have wireless mouse and keyboard turn it off. Choose one of these two both work.

Resources