radimitrov / CSharpShellApp

81 stars 18 forks source link

Mvvm toolkit attribute issue #390

Closed sedoLevi609 closed 1 month ago

sedoLevi609 commented 1 month ago

@radimitrov If I use mvvm toolkit attributes,like ObservableObjectAttribute I get the following exceptions: Argument 1: cannot convert from 'System.ComponentModel.PropertyChangingEventArgs' to 'string' and Argument 1: cannot convert from 'System.ComponentModel.PropertyChangedEventArgs' to 'string' for every ObservablePropertyAttribute. My code(Card is just an abstract class but that's not important I believe):

[ObservableObject] public partial class Creature : Card { readonly int maxStrength;

[ObservableProperty]
int strength;

readonly int maxDefense;

[ObservableProperty]
int defense;

}

This is the Card class(Land class only has a private constructor):

public abstract class Card : GraphicsView, IDrawable { readonly List\<Land> costs = new List(); readonly string imagePath;

public Card()
{
    Drawable = this;
}

public void Draw(ICanvas canvas, RectF rect)
{
    IImage image = PlatformImage.FromStream(Ui.GetEmbedded(String.Join(".", ["Images", imagePath])));
    canvas.DrawImage(image, 0, 0, image.Width, image.Height);

    if (Power.HasValue && Toughness.HasValue)
    {
        canvas.DrawString($"{Power.Value}/{Toughness.Value}", 50, 50, 10, 10, HorizontalAlignment.Right, VerticalAlignment.Bottom);
    }
}

protected int? Power => null;
protected int? Toughness => null;
protected int? PowerModifier => null;
protected int? ToughnessModifier => null;

}

Please fix it!

sedoLevi609 commented 1 month ago

Figured it out I guess: graphicsview is already implementing INotifyPropertyChanged