question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reduce depencency on WPF

See original GitHub issue

Is your feature request related to a problem? Please describe.

MVVM does not have a dependency on WPF or any other presentation framework. This is true for both MVVM-Light and its successor MVVM Toolkit MVVM Dialogs codebase could be split between core (or base) package, which only relies on .Net Standard and presentation package(s) responsible for the presentation layer implementation.

Describe the solution you’d like

Introduce a new project and NuGet package, which declares framework-agnostic types and interfaces such as IModalDialogViewModel

Draft PR #176 demonstrates the general idea.

Describe alternatives you’ve considered Keeping dialogs away from the presentation layer could be achieved (maybe?) with a wrapper:

Copy and rename the interface

public interface IModalDialogViewModelStandard : INotifyPropertyChanged
{
    bool? DialogResult
    {
        get;
    }
}

Implement dialog VM outside of presentation layer using IModalDialogViewModelStandard

public class MyDialogVM : ViewModelBase, IModalDialogViewModelStandard 
{
    private bool? dialogResult;
    public bool? DialogResult
    {
        get => dialogResult;
        private set => Set(nameof(DialogResult), ref dialogResult, value);
    }
}

Wrap IModalDialogViewModelStandard inside a IModalDialogViewModel

public class ModalDialogViewModelWrapper<T> : ObservableRecipient, IModalDialogViewModel where T : IModalDialogViewModelStandard
{
    readonly T modalDialogViewModel;
    public ModalDialogViewModelWrapper(T modalDialogViewModel)
    {
        this.modalDialogViewModel = modalDialogViewModel;
    }
    public bool? DialogResult => modalDialogViewModel.DialogResult;
}

IDialogTypeLocator needs to associate a ViewModels from non-presentation assembly to Window in the presentation layer. Window could be wrapped in IWindow to override IWindow.DataContext

What’s your opinion @FantasticFiasco ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:95 (40 by maintainers)

github_iconTop GitHub Comments

2reactions
FantasticFiascocommented, Jan 4, 2022

@FantasticFiasco BTW, there are a few other RPs I wanted to send. If you’d be open to them, they should be done before this abstraction:

  • Reduce amount of sample projects by multitargeting sample projects to both .Net Core and .Net Framework
  • Remove support for .Net Frameworks before 4.5.2. They reached end of life and are not supported by VS 2022.
  • Replace MVVMLight with CommunityToolkit.Mvvm

What do you think?

I’m happy to announce that @virzak made huge impact with these implementations. I’m about to enbark on your path now @mysteryx93. Wish me luck! 😄

1reaction
FantasticFiascocommented, Jan 5, 2022

Of course it can be made in increments. #180 is an increment and I’m sure there will be more increments in your fork.

You can’t really expect that a maintainer will accept a total re-write of a codebase. As maintainer you have to own the codebase and understand every intrinsic detail. You can’t really do that if you receive a total rewrite.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I reduce dependencies in my bloated WPF ...
I use Autofac for DI and I try to keep to the MVVM pattern. I used a ViewModel, until one wasn't enough. I...
Read more >
Dependency property callbacks and validation - WPF .NET
You can create dependencies between properties on an element, by using coerce-value callbacks and property-changed callbacks in combination. For ...
Read more >
FULL STACK WPF (.NET CORE) MVVM #28 - YouTube
I clean up my dependency injection registration setup by using extension methods for the host builder. This is not necessary and does not ......
Read more >
Creating Reusable Controls - WPF TUTORIALS - YouTube
Creating reusable controls is critical for reducing duplication and ... 9:55 - Removing Duplication 11:05 - Content Dependency Properties ...
Read more >
Reducing the size of a WPF app : r/visualbasic
I am currently working on a rather simple WPF app (. ... afterwards it seems that all dependencies are readded during the build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found