简体   繁体   English

Visual Studio 中从代码隐藏切换到 Xaml 代码的捷径是什么?

[英]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.我习惯于按 shift+F7 在我的代码和设计器之间切换(加载需要 1 到 5 秒)然后我总是必须单击查看 Xaml 来修改我的 XAML 代码。

I don't find any shortcut in Tools/Options/Keyboard to go directly (from code behind to XAML code).我在 Tools/Options/Keyboard 中没有找到任何可以直接访问的快捷方式(从代码隐藏到 XAML 代码)。 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.在 VS2008 中,在 XAML 页面 (.xaml.cs) 的代码隐藏中,按 SHIFT-F7 会将您带到 XAML 设计器或 XAML 代码页,具体取决于哪个具有最新焦点。 Pressing SHIFT-F7 again will take you from the XAML code page to the designer and vice versa.再次按 SHIFT-F7 会将您从 XAML 代码页带到设计器,反之亦然。

While in the XAML designer or XAML code page, pressing F7 takes you to the related code behind page.在 XAML 设计器或 XAML 代码页中,按 F7 会将您带到相关的代码隐藏页面。

UPDATE.更新。 Applicable for later versions (eg MS VS 2015 too).适用于更高版本(例如 MS VS 2015)。

I've finally found the solution for VS 2010:我终于找到了 VS 2010 的解决方案:

F7: switch between Code Behind and XAML (Design or Markup depending on last used) F7:在代码隐藏和 XAML 之间切换(设计或标记取决于上次使用)
Shift+F7: switch between XAML (Design) and XAML (Markup). Shift+F7:在 XAML(设计)和 XAML(标记)之间切换。

F7 shortcut mapping should look like "View.ToggleDesigner (F7 (Global))" F7 快捷方式映射应类似于“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). Shift+F7 快捷方式映射应该类似于“View.ViewDesigner (Shift+F7 (Global))”和“View.ViewMarkup (Shift+F7 (HTML Source Editor View))”(一个快捷方式的两个映射)。

When I first installed VS2010, my keyboard mappings were set to (Default).当我第一次安装 VS2010 时,我的键盘映射被设置为(默认)。 The default setting had View.ViewDesigner mapped to "Shift-F7 (HTML Editor Source View)".默认设置将 View.ViewDesigner 映射到“Shift-F7(HTML 编辑器源视图)”。 To get the shortcut to work in all views, I had to change the mapping to "Shift-F7 (Global)".为了让快捷方式在所有视图中工作,我不得不将映射更改为“Shift-F7(全局)”。 Changing the keyboard mappings to "Visual C# 2005" worked as well.将键盘映射更改为“Visual C# 2005”也有效。

For VS 2012, F7 builds the solution.对于 VS 2012,F7 构建解决方案。

  • Shift-F7: goes from code-behind to XAML Ctrl Shift-F7:从代码隐藏到 XAML Ctrl

  • Ctrl-Alt-0: goes from XAML to code-behind Ctrl-Alt-0:从 XAML 转到代码隐藏

It's in the View menu, but not an obvious keystroke.它在“视图”菜单中,但不是明显的按键。 Tools-Customize...Keyboard... to customize it.工具-自定义...键盘...自定义它。

For VS 2008:对于 VS 2008:

F7 goes from XAML to Code Behind, Shift-F7 goes from Code Behind to XAML F7 从 XAML 到代码隐藏,Shift-F7 从代码隐藏到 XAML

-->Tools --> Options --> Keyboard Seek "view.view.. --> 工具 --> 选项 --> 键盘搜索“view.view..

View.ViewCode [F7] (global) Assign View.ViewCode [F7](全局)分配

View.ViewDesigner [Shif+F7] (global) Assign View.ViewDesigner [Shif+F7](全局)分配

Download dpack for visual studio (free) - then F7 will always switch to the "other" view.下载 Visual Studio 的 dpack(免费) - 然后 F7 将始终切换到“其他”视图。 Plenty of other great features in there too.还有很多其他很棒的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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