I just wanted to simplify the code a lot and I have such a XAML code.

<ToggleButton x:Name="LogToggleBtn" Click="LogToggleBtn_Click"/> 

This is the C # code on the ToggleBtn click.

 SetSettingsValue("LOGGING", LogToggleBtn.IsChecked == true ? "1" : "0"); 

How can this be simplified to do this without a method? In the sense of calling this method with parameters on conditions, but without C # code.

I know almost nothing about MVVM, if you can skip the solution. :)

SetSettingsValue - Method, takes two arguments, string and string. For some other elements, the exact same method is reserved only with string and int.

  • Uh, nothing is clear, but you can write a command and a converter, but the code will come out more - Andrey NOP
  • @ AndreiNOP How not to understand? I explained the need to call the method SetSettingsValue with the String and String parameters, and check if the Checkbox is checked, then we call this method with the parameters "TEST" "0", and if we check "TEST" "1". I just think it can be cut in XAML. - MairwunNx
  • one
    To shorten is if you initially use MVVM, where you can thrust the call to your method into the set of the desired property, and it’s unlikely that it will be reduced from what is now reduced. - EvgeniyZ
  • Well, thank you.) - MairwunNx

0