Closed Shadowblitz16 closed 5 months ago
I don't know if I should make a new issue just to ask this question but...
How do ICommand's work?
From the examples I find online It looks like ICommand only covers the main event aka
How would I bind a ICommand property to a paint event?
This is kinda what I have...
<Window xmlns="http://schemas.alternetsoft.com/ui/2021"
xmlns:x="http://schemas.alternetsoft.com/ui/2021/uixml"
x:Class="SMBY.MainView"
Title="SMBY" StartLocation="CenterScreen"
Size="800,600" Layout="Vertical">
<Control UserPaint="true" Paint="{Binding PaintView}" VerticalAlignment="Fill"/>
<HorizontalStackPanel VerticalAlignment="Bottom" HorizontalAlignment="Center">
<Button Name="Edit" Text="Edit" Click="{Binding Edit}"/>
<Button Name="Play" Text="Play" Click="{Binding Play}"/>
</HorizontalStackPanel>
<EngineView Visible="false" DataContext="{Binding EngineViewModel}"/>
<EditorView Visible="false" DataContext="{Binding EditorViewModel}"/>
</Window>
using System.ComponentModel;
using Alternet.Drawing;
using Alternet.UI;
using SMBY;
public class MainViewModel : ViewModelBase
{
public EditorViewModel? EditorViewModel { get; }
public EngineViewModel? EngineViewModel { get; }
public ICommand? Edit { get; }
public ICommand? Play { get; }
public ICommand? PaintView { get; }
public MainViewModel()
{
EditorViewModel = new();
EngineViewModel = new();
}
}
I cannot suggest to use Binding for now. It is slow and will be rewritten in future.
I cannot suggest to use Binding for now. It is slow and will be rewritten in future.
ok thankyou
EDIT: @generalloki what would you recommend to maintain clean code? MVC, MVP?
I need a way to tie my game logic, editor ui and binary file format together.
@Shadowblitz16, I am moving this to discussions as this will be done after we redo Binding. Also, do you know any good simple MVVM examples? Is there any in Wpf or Maui?
Can we have a MVVM example?