0

I can't for the life of me figure out how to do this, if possible.

When using explicit expressions as values for EventHandlers or actions on components, is there a way to define how you want them formatted when using code cleanup/formatting functions in the IDE? In this instance, I use Rider and I've tried going through all settings in the code style options to no avail.

Here's an example, the ValueChanged and TextChanged attributes here use expressions and I'd like them to be formatted something along the lines of this:

<DxComboBox
    Data="@(cities ?? [])"
    Value="@City"
    ValueChanged="@((City? city) =>
                  {
                      if (city is not null && city != City)
                          OnCityChanged(city);
                  })"
    TextChanged="@((string? cityName) =>
                 {
                     if (cityName is not null && cityName.Length > 0 && cityName != City?.Name)
                         OnCityChanged(new City(cityName));
                 })"
    AllowUserInput="true"
    ListRenderMode="ListRenderMode.Virtual"
    SearchMode="ListSearchMode.AutoSearch"
    SearchFilterCondition="ListSearchFilterCondition.Contains"/>

But no matter what I try, it will always get formatted into this:

<DxComboBox
    Data="@(cities ?? [])"
    Value="@City"
    ValueChanged="@((City? city) => { if (city is not null && city != City) OnCityChanged(city); })"
    TextChanged="@((string? cityName) => { if (cityName is not null && cityName.Length > 0 && cityName != City?.Name) OnCityChanged(new City(cityName)); })"
    AllowUserInput="true"
    ListRenderMode="ListRenderMode.Virtual"
    SearchMode="ListSearchMode.AutoSearch"
    SearchFilterCondition="ListSearchFilterCondition.Contains"/>

which, to me, is way less easy to read than the formatting with line breaks.

Is there a way to configure this using editorconfig?

1
  • When you make some appropriately named functions in the code-behind then this problem goes away. It is a matter of taste but I think there is way too much business logic here for a markup section. Commented May 1 at 11:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.