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

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

Related

How to undo a "Reset Toolbox" in VS2008?

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.

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.

Toolbar Button with Context Menu? Like New Project Button in Visual Studio

I need a toolbar button similiar to the "New Project" button in the standard Visual Studio toolbar. When clicked, it pops up a dialog. However, it also has a small little down-arrow next to the icon graphic that, when clicked, expands a context menu with more options.
Is there a standard control available with this functionality?
I don't think there's built in functionality for a SplitButton in WPF currently. Here's another thread that may help you out though:
WPF SplitButton?
You could combine a couple of controls together to make one fairly quickly. Might as well make a new UserContol out of it that can be re-used throughout your app as well.
Also, a quick search on WPF SplitButton will return a lot of examples on how to make one or you could get one off of CodeProject or CodePlex (though I'm not sure if they'll come with a image property automatically).

VS2010 Winforms Usercontrol changes not showing in parent form

I've created a series of usercontrols. Dragged one of the controls to the main form. It shows OK. Went back and made a change to the design of the user control. Rebuilt project. Cleaned project. manually removed all project binaries including the obj folder. Change still doesn't show on the usercontrol hosted on the main form. Dragging a new instance of the control from the tool box only shows the old version of the control.
Completely removed the controls from the toolbox and adding them again fixed the problem, but surely I don't have to do this everytime I make a change? All user controls are in the same assembly as the main form. Tool>Options>Windows Forms Designer>Auto toolbox Populate is set to true. Any ideas most appreciated. Thx
Do not add the control to the toolbox yourself. This puts a copy of the assembly in a private directory. Yes, this copy does not get updated automatically, you get the old control.
Rely on the "Auto toolbox populate" setting. It automatically adds any controls you have in your loaded project(s) to the toolbox. The added controls are at the top of the toolbox.
I agree with answer 1 that that is what is supposed to happen, and often does. But it doesn't always work and will work partially sometimes.
For example my current Solution.
Project 1 namespace ToolsTester - This is just a temporary form to test the view tools in the 2nd project.
Project 2 namespace UltimateFileFinder - This has three views.
The first 2 views (user controls) UltFilesView and UltSlideShow appeared as usual on the toolbar so I could drag them onto ToolsTester to try them out.
Then I added another user control UltPanel, this will not go onto the toolbox. Though it compiles without errors.
I have come across this problem a few times, sometimes removing and reasserting the reference fixes it. Other times I would have to remove the test project and create a new one.
I tested Visual Studio (full version) before release and this was one of the areas I reported back, so the problem was known pre-release.
This project I am on now I know that I will need to remove the test project and create a new one, in this case the tester is only a few simple caller and event responses, that is not always the case, there are times when the tester project can be quite complex because it is mimicing the target that the tools will be part of.

Visual Studio design time event handling

I am trying to create a WPF wizard control in visual studio. I am successful except I would like to navigate the pages in design time by clicking the next and previous buttons. The pages are being written in xaml. I can navigate the pages by going to the properties window and changing the selected index, but I would like something more user-friendly. I remember doing something similar in a winforms project having something to do with overriding maybe wndproc and listening to mouse click events from the designer.
So I've been googling and I can't seem to google the right words to bring this up.
Can anyone please help!
You need to create a custom Adorner as described here. There are two walkthroughs there that should help.
Ultimately, you would need to overlay a transparent button on top of your actual buttons. Then in the click handlers you'd update your selected item/index.

Resources