Skip to content

ViewModels in Core layer (Chapter 10) #2

Description

@macik1423

Why You put ViewModels folder in Core layer?
I am wondering how to achive clean architecture in my solution. I have projects: Core (Models, Messages, ViewModels), Mobile (Maui project), Shared (Dto projects). I have
<PanGestureRecognizer PanUpdated="PanGestureRecognizer_PanUpdated"/>
in my View, which I pass it to the ViewModel via:

private void PanGestureRecognizer_PanUpdated(object sender, PanUpdatedEventArgs e)
{
    var panUpdatedCommand = ((MyViewModel)BindingContext).PanUpdatedCommand;
    panUpdatedCommand.Execute(e);
}

Here I pass the EventArgs: PanUpdatedEventArgs which depends on Maui.

Then I can't use RelayCommand in MyViewModel like this:

 [RelayCommand]
 private void PanUpdated(PanUpdatedEventArgs e)
 {
     switch (e.StatusType)
     {
         case GestureStatus.Started:
             ...

         case GestureStatus.Running:
             ...

         case GestureStatus.Canceled:
             ...

         case GestureStatus.Completed:
             ...
     }
 }

because PanUpdatedEventArgs and GestureStatus come from Maui library but my ViewModel should be independent due to clean architecture. How can I achive that?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions