Giter Site home page Giter Site logo

thoemmi / tinylittlemvvm Goto Github PK

View Code? Open in Web Editor NEW
132.0 17.0 23.0 322 KB

A small MVVM library for WPF built on top of MahApps.Metro, supporting .NET Framework >= 4.7.2 and .NET Core >= 3

License: MIT License

C# 100.00%
c-sharp mahapps wpf wpf-mahapps mvvm dotnet-core3 dotnet-framework

tinylittlemvvm's Introduction

TinyLittleMvvm

This is a small MVVM library I wrote, because I implemented the same stuff over and over again in several projects.

I tried Caliburn Micro, MVVM Light and others, but none of them met my demands satisfactory.

My requirements were:

The main purpose of this library is to speed up the development of small to midsize WPF applications using MahApps.Metro.

With the second major release the focus shifts somewhat. The main package, TinyLittleMvvm, concentrates on making WPF more MVVM-friendly. All features related to MahApps.Metro have been moved to a separate package, TinyLittleMvvm.MahAppsMetro.

Features

TinyLittleMvvm provides following features:

Builds and Packages

Channel Build NuGet Package
Unstable Build Nuget (with prereleases)
Stable Build Nuget

tinylittlemvvm's People

Contributors

ahmediddma avatar thoemmi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinylittlemvvm's Issues

Binding views to view models

First of all thank you for this very useful library.
Is it possible with TinyLittleMvvm to assign views to view models also dynamically in the start-up code, instead of doing it statically in the xaml file? Would be possible to assign different instances of the same view-model to different views?
Is there any schedule available for the release of a stable v2?

Can't load assembly into 3dsmax

Because the assembly requires strict compliance version MahApps.Metro.dll, and I have installed the dll version 1.6.0

System.IO.FileLoadException: Could not load file or assembly 'MahApps.Metro, Version=1.3.0.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044) File name: 'MahApps.Metro, Version=1.3.0.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f' ---> System.IO.FileLoadException: A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

Clip2net_190413152454

RelayCommand with parameters

Is it possible to get parameters when executing a relay command ? For instance the "Name" property of the object issuing the command? I am using some checkboxes in an ItemsControl.ItemTemplate, and would like to be able to determine which one was checked/unchecked.
Is it possible to use RelayCommand to detect a status change for a checkbox ? If yes, how to get the actual status of the checkbox (checked or unchecked)

Changes required to support MahApps.Metro 2.0+ and above

Nice project, thanks for sharing.
For those trying to figure out how to get going with the non-beta versions of MahApps a few handy pointers.
It needs to be updated to work with the new Theme manager
https://mahapps.com/docs/guides/migration-to-v2.0
https://mahapps.com/docs/themes/thememanager

.NET CORE 3.0 is marked EOL, so it's a good opportunity to update to 3.1 marked as LTS https://dotnet.microsoft.com/platform/support/policy/dotnet-core

This is what I did.. Hope this helps you out..

In TinyLittleMvvm.csprj

Updated to 3.1 (optional)

<TargetFramework>netcoreapp3.1</TargetFramework>

Updated packages to

<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.7" />
<PackageReference Include="MahApps.Metro" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.7" />

In DialogManager.cs, FlyoutManager.cs

Replace all occurrences

Uri("pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml")

With

Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml")

In TinyLittleMvvmDemo.cs

Updated to 3.1 (optional)

<TargetFramework>netcoreapp3.1</TargetFramework>

Updated packages to

<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.7" />

In SampleFlyout.cs

Add the new theming:

using ControlzEx.Theming;

Replace these functions with:

        public SampleFlyoutViewModel() {
            this.AccentColors = ThemeManager.Current.Themes
                .GroupBy(x => x.ColorScheme)
                .OrderBy(a => a.Key)
                .Select(a => new AccentColorMenuData {
                    Name = a.Key,
                    ColorBrush = a.First().ShowcaseBrush
                })
                .ToList();
            var theme = ThemeManager.Current.DetectTheme(Application.Current);
            _currentAccentColor = AccentColors.Single(accent => accent.Name == theme.ColorScheme);

            OkCommand = new RelayCommand(OnOk, () => !HasErrors);
            CancelCommand = new RelayCommand(Close);
        }

        public AccentColorMenuData CurrentAccentColor {
            get { return _currentAccentColor; }
            set {
                if (_currentAccentColor != value) {
                    _currentAccentColor = value;
                    ThemeManager.Current.ChangeThemeColorScheme(Application.Current, value.Name);
                }
            }
        }

*xaml.cs files in the demo application

Could you please explain why there are no corresponding *xaml.cs files for the different view *.xaml files from the demo application?
I am looking for the *.cs files with the definitions of the different classes referenced from the different views.

Flyout Tasks Never Complete

When using an AsyncRelayCommand and the FlyoutManager, the task is never completed, so the command's CanExecute check always returns false.

Flyout view in the demo

I have a question about the behaviour of the flyout view in the TinyLittleMvvm demo application. If I open the flyout view (by clicking the button "show sample flyout") and press then the arrow to minimize the view (instead of pressing ok or cancel), the button "show sample flyout" in the main view gets disabled and I cannot return to the flyout view anymore.

Use LibLog for logging

Currently TinyLittleMvvm depends on NLog. This dependency should be removed, because it forces users of TinyLittleMvvm to use NLog. Instead, LibLog should be used as it abstracts any common logging framework.

Compatible Mvvm ligth?

Is compatible con mvvm ligth

SimpleIoc.Default.Register<IDialogManager, IDialogService>(); ??

thanks =)

Review project metadata

  • Use a common Directory.Build.props file for metadata such as copyright, license etc
  • Review package tags
  • ...

Support of service scopes

IServiceProvider supports service scopes.

Check if TinyLittleMvvm respects scopes, e.g. a separate scope for a window or a child scope for an embedded content control.

Code breaks if program starts other than AppName.App();

Had this project pull from Nuget and found that it couldn't start.
After scratching my head and realized that all compiler errors lead to how the app starts, ( I had an additional class to invoke resolving assembly resources before calling App.Main(); )

It would be nice to tell other that this script will only works when executed from App.Main();, Or just use default program starts in the application property.

(AFAIK, Strange behavior happens between xaml of the project and AppBootstrapper.cs)

Regards,
J

GetErrorForProperty

Hi @thoemmi

Was wondering can you add the GetErrorForProperty method to PropertyChangedBase

Like this https://github.com/OxyProgrammer/XPence/blob/master/WPF%20Client/XPence/XPence.Infrastructure/BaseClasses/ViewModelBase.cs

So I can use it in my project

protected override string GetErrorForProperty(string propertyName)
        {
            string error = null;
            switch (propertyName)
            {
                case "ICCID":
                    if (string.IsNullOrWhiteSpace(ICCID))
                        error = "ICCID is mandatory.";
                    else
                    {
                        if (null != ICCID && ICCID.Length > 20)
                            error = "Max 20 chars permitted.";
                    }
                    break;
                case "IMSI":
                    if (string.IsNullOrWhiteSpace(IMSI))
                        error = "ICCID is mandatory.";
                    else
                    {
                        if (null != IMSI && IMSI.Length > 15)
                            error = "Max 15 chars permitted.";
                    }
                    break;
                case "MSISDN":
                    if (string.IsNullOrWhiteSpace(MSISDN))
                        error = "MSISDN is mandatory.";
                    else
                    {
                        if (null != MSISDN && MSISDN.Length > 15)
                            error = "Max 15 chars permitted.";
                    }
                    break;
            }
            CommandManager.InvalidateRequerySuggested();
            return error ?? Entity[propertyName];
        }

If that makes any sense sorry still beginner dev

Position="Left"?

Hi there - enjoying the project! Hopefully a simple question, but adding Position="Left" to the Flyout control does not make the control appear from the left. Is there a way to do this?

Thanks, Andrew

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.