Search code examples
c#wpfxamlvisual-studio-2019indentation

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.

Here is the App.xaml.cs when I manually format it :

App.xaml.cs

When I go back to the line, my cursor goes here :

App.xaml.cs cursor

If I format the document (Ctrl+K, Ctrl+D) :

App.xaml.cs auto-format

I don't have this problem in UWP, and I don't know what to do to solve this problem. Here is an example of my cursor when I go back to the line in UWP :

cursor example UWP

Options -> Text Editor -> C# -> Tabs :

C# options

Thanks to those who will try to help me and sorry if my English isn't perfect.


Solution

  • 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. If you're having different behaviors on the same language but different projects, look for such a file and change the setting there.