简体   繁体   English

如何修复 WPF (Visual Studio 2019) 中的 xaml.cs 缩进问题?

[英]How to fix a xaml.cs indentation problem in WPF (Visual Studio 2019)?

I am currently developing an application in WPF (.NET Core) and I'm encountering an indentation problem.我目前正在WPF (.NET Core)中开发应用程序,我遇到了缩进问题。

Here is the App.xaml.cs when I manually format it:这是我手动格式化后的App.xaml.cs

应用程序.xaml.cs

When I go back to the line, my cursor goes here:当我 go 回到线路时,我的 cursor 在这里:

App.xaml.cs 游标

If I format the document ( Ctrl+K, Ctrl+D ):如果我格式化文档( Ctrl+K, Ctrl+D ):

App.xaml.cs 自动格式化

I don't have this problem in UWP , and I don't know what to do to solve this problem.我在UWP没有这个问题,我不知道如何解决这个问题。 Here is an example of my cursor when I go back to the line in UWP:下面是我cursor当我go回到UWP那一行的例子:

光标示例 UWP

Options -> Text Editor -> C# -> Tabs :选项->文本编辑器-> C# ->选项卡

C#选项

Thanks to those who will try to help me and sorry if my English isn't perfect.感谢那些愿意帮助我的人,如果我的英语不完美,我深表歉意。

There is the chance of changing the indentation settings (among others) on a per-project basis by providing a .editorconfig file, that will override some settings in Visual Studio project.通过提供.editorconfig文件,可以在每个项目的基础上更改缩进设置(以及其他),这将覆盖 Visual Studio 项目中的某些设置。 If you're having different behaviors on the same language but different projects, look for such a file and change the setting there.如果您在同一语言但不同的项目上有不同的行为,请查找这样的文件并更改那里的设置。

Welcome to SO.欢迎来到 SO。

You're changing the setting for XAML, but the code you show is C#. Try editing the C# settings instead.您正在更改 XAML 的设置,但您显示的代码是 C#。尝试改为编辑 C# 设置。

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

相关问题 将XAML.CS嵌入到Powershell WPF工具中 - Embed XAML.CS into Powershell WPF Tool WPF按钮单击xaml.cs - Wpf button click in xaml.cs 如何修复Visual Studio 2019中的错误CS0246 - How to fix error CS0246 in Visual Studio 2019 如何在viewmodel(.cs)中调用窗口(.xaml.cs)中的方法而不在wpf中引入新引用 - How to call method in window (.xaml.cs) from viewmodel (.cs) without introducing new references in wpf 从.xaml.cs文件中“转到定义”将我带到.gics文件而不是Visual Studio 2015中的.xaml文件 - “Go To Definition” from a .xaml.cs file takes me to .g.i.cs files instead of to .xaml file in Visual Studio 2015 在Visual Studio 2010中,为什么“计算代码指标”会忽略.xaml.cs文件? - In Visual Studio 2010, why does “Calculate Code Metrics” ignore .xaml.cs files? 如何恢复损坏的xaml.cs文件? - How to recover corrupted xaml.cs file? 我的第一个项目使用 C# 和 WPF - 如何设置变量 from.xaml.cs 出现在文本框中? - My first project using C# & WPF - how to set a variable from .xaml.cs to appear in the textbox? 如何绑定 wpf ComboBox 以更改语言而不写入 xaml.cs? - How to bind wpf ComboBox to change the Language withougt writting into the xaml.cs? 如何将WinForm用户控件添加到WPF中,以便我可以在xaml.cs文件中引用它 - How to add WinForm User Control Into WPF so that I can reference it in the xaml.cs file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM