简体   繁体   中英

What is the shorcut in visual studio to switch from code behind to Xaml Code?

I'm used to press shift+F7 to switch between my code behind and the designer (which takes between 1 and 5 seconds to load) then I always have to click on View Xaml to modify my XAML code.

I don't find any shortcut in Tools/Options/Keyboard to go directly (from code behind to XAML code). How can I do that ?

In VS2008, while in code-behind of your XAML page (.xaml.cs), pressing SHIFT-F7 will take you to the XAML Designer or the XAML code page, depending on which one had the latest focus. Pressing SHIFT-F7 again will take you from the XAML code page to the designer and vice versa.

While in the XAML designer or XAML code page, pressing F7 takes you to the related code behind page.

UPDATE. Applicable for later versions (eg MS VS 2015 too).

I've finally found the solution for VS 2010:

F7: switch between Code Behind and XAML (Design or Markup depending on last used)
Shift+F7: switch between XAML (Design) and XAML (Markup).

F7 shortcut mapping should look like "View.ToggleDesigner (F7 (Global))"
Shift+F7 shortcut mapping should look like "View.ViewDesigner (Shift+F7 (Global))" and "View.ViewMarkup (Shift+F7 (HTML Source Editor View))" (two mappings for one shortcut).

When I first installed VS2010, my keyboard mappings were set to (Default). The default setting had View.ViewDesigner mapped to "Shift-F7 (HTML Editor Source View)". To get the shortcut to work in all views, I had to change the mapping to "Shift-F7 (Global)". Changing the keyboard mappings to "Visual C# 2005" worked as well.

For VS 2012, F7 builds the solution.

  • Shift-F7: goes from code-behind to XAML Ctrl

  • Ctrl-Alt-0: goes from XAML to code-behind

It's in the View menu, but not an obvious keystroke. Tools-Customize...Keyboard... to customize it.

For VS 2008:

F7 goes from XAML to Code Behind, Shift-F7 goes from Code Behind to XAML

-->Tools --> Options --> Keyboard Seek "view.view..

View.ViewCode [F7] (global) Assign

View.ViewDesigner [Shif+F7] (global) Assign

Download dpack for visual studio (free) - then F7 will always switch to the "other" view. Plenty of other great features in there too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM