在Visual Studio(2013/2015/2017)中,C#文件的" 文档大纲"窗口始终为空,("没有要显示所选文档的项目.").看来,这个功能不是(尚未/不再)实现的.
但是如何查看文件的结构?有没有实现此功能的扩展?
使用Solution Explorer和Class View不是解决方案. 在旧的Visual Studio 2003中,我确实使用了自编写的加载项,因为它很容易读取结构.(还有其他工具,但我再也找不到了).所以我在这里问你知道哪种解决方案.:-)
编辑:类似的问题还发现: 如何在Visual Studio中显示代码大纲?
如何使用绑定和 DataTemplate 呈现字符串、数字或视图模型?
我正在寻找 WPF ContentControl 的 MAUI 替代品。
具有ContentViewContent 属性,但这是来自 type View。具有ContentPresenterContent 属性,但这也来自 type View。<Ignorable>WTF,为什么它只能呈现一个视图,而不被命名为 ViewPresenter ???有时 MAUI 很奇怪。</Ignorable>
如何通过为每种数据类型定义数据模板来呈现任何内容?
class PropertyViewModel {
public string Name {get;set;}
public object Value {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
<Page.Resources>
<DataTemplate DataType="System.String">
<Entry Text="{Binding}/>
</DataTemplate>
<DataTemplate DataType="System.Int32">
<NumberPicker Value="{Binding}/>
</DataTemplate>
.. more templates, eg. DatePicker for System.DateOnly
</Page.Resources>
<DockLayout>
<Label Text="{Binding Name}
<TemplatedContenView Content={Binding Value}/>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
TemplatedContenView 或 ContentControl(MAUI 中不存在)可以对不同类型的值使用不同的模板。在 WPF 中,ContentControl 使用 ContentTemplate、ContentTemplateSelector,或者如果未指定,则它会查找资源来查找模板。
<Ignorable>对于 MAUI,我经常有一种感觉,我必须不断地重新发明 …
如何在代码后面找到带有密钥的资源?
也相当于{DynamicResource}/{StaticResource}标记扩展。
在 WPF 中,解决方案是:
Style=(Style)FindResource("MyStyleKey");
How to do this in MAUI?,因为 FindResource 不存在。
我不想手动挖掘 Application.Resources 中的所有合并字典
我想知道为什么还没人问,我是否忽略了这个简单的解决方案?
编辑1:
哈哈,好的,我没有想到要检查 ResourceDictionary 是否递归搜索自身。但这只是工作的一半。你仍然需要向后遍历当前元素树。
因此,为什么 FindResource 没有默认实现的问题仍然是合理的?或者其他地方是否已经有一个函数可以做到这一点?
编辑2:
我把问题带到了更重要的一点:如何找到资源,而不是如何分配。
最初的问题是“如何在代码后面分配带有键的样式”