XAML中的#region [英] #region in XAML

查看:117
本文介绍了XAML中的#region的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上不喜欢代码中的#region. 但是出于某种原因使我发疯,我希望将它们包含在我的XAML中.我希望整个部分都具有类似#region的内容并将其折叠(例如,我的< Window.CommandBindings>,< Grid.* Definitions>,< Menu>,< Toolbar>等.)

I actually don't like #region in my code. BUT for some reason call me crazy, I would like to have them in my XAML. I would like whole sections to have a #region-like thing and collapse them (e.g. my <Window.CommandBindings>, <Grid.*Definitions>, <Menu>, <Toolbar>, etc..

这存在吗?如果不是,那么< RegionCollapse>

Does this exist? If not, how about <RegionCollapse>

推荐答案

OP注意:这是原始的正确答案在某些方面仍然是一个很好的办法,对于包括我在内的一些最佳答案.但我认为这最好地回答了原始问题.

OP NOTE: this was the original right answer and in some ways still is a good and for some best answer including me. BUT this answers the original question best I think.

Visual Studio 2015最终在XAML中添加了对区域的支持.您将您的区域代码括起来,如下所示:

Visual Studio 2015 finally adds support for regions in XAML. You enclose your regional code like this:

<!--#region RegionName-->

All Your XAML In Here

<!--#endregion-->

这将在开始行的左侧添加一个折叠图标,您可以使用该图标来展开/折叠区域.

This will add a collapse icon to the left of starting line, using which you can expand/collapse the region.

不知道这实际上有多方便,因为我们已经可以折叠/扩展XAML编辑器中的任何节点.无论如何,它都在那里.

Don't know how handy this would practically be since we can already collapse/expand any node in XAML editor. It's there anyway if you want to use.

这篇关于XAML中的#region的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆