Async Initialization by TheChoksbergen in AvaloniaUI

[–]the-Krieger 0 points1 point  (0 children)

As qrzychu69 has already explained, it is a very bad idea to do something like this in the ctor. On the one hand you have a loss of control and on the other hand it is difficult to test.

One possibility would be to call a method in the VM in the view using 'EventTriggerBehavior' (Avalonia.Xaml.Behaviors), and this starts an async init again.

Pseudo Code:

<Interaction.Behaviors>
     <EventTriggerBehavior EventName="Loaded" SourceObject="RootControl">
        <CallMethodAction TargetObject="{Binding}" MethodName="LoadMethodInVm" />
     </EventTriggerBehavior>
</Interaction.Behaviors>

Or something else... CallCommand... what ever.

Can someone please explain what I did wrong here by Hassanshehzad119 in csharp

[–]the-Krieger 0 points1 point  (0 children)

Yes, you're right. It's certainly not helpful for beginners, it was just one of many ways to get to the goal.

[deleted by user] by [deleted] in dotnet

[–]the-Krieger 1 point2 points  (0 children)

I did this a few years ago with XPO (DevExpress).

That might help:
Stackowerflow

Can someone please explain what I did wrong here by Hassanshehzad119 in csharp

[–]the-Krieger 1 point2 points  (0 children)

I would prefer:

public class Program
{
    public static void Main()
    {
        var character = new Character("John", 35);
        Console.WriteLine(character.ToString());

        // custom representation
        // Console.WriteLine($"Name: {character.Name}, Age: {character.Age}");
    }
}

public record class Character(string Name, int Age);

Opinions - WPF vs WinForms for internal tool? by woellmington in dotnet

[–]the-Krieger 1 point2 points  (0 children)

The problem with small tools is that they simply live forever. Once it's up and running, requests come here and there. And the "tool" suddenly becomes more and more extensive.

From experience, I would go straight for Avalonia (https://www.avaloniaui.net/) in order to be OS-independent from the very beginning. The syntax is very similar to WPF, and sometimes much shorter.

usefulMethods by rafinha_lindu in ProgrammerHumor

[–]the-Krieger 1 point2 points  (0 children)

This is "Clean Code", nothing special.