Skip to content

Mvvm for Revit with RelayCommand and ObservableObject to use with PropertyChanged.Fody package.

License

Notifications You must be signed in to change notification settings

ricaun-io/ricaun.Revit.Mvvm

Repository files navigation

ricaun.Revit.Mvvm

Mvvm for Revit with RelayCommand, AsyncRelayCommand and ObservableObject to use with PropertyChanged.Fody package.

Revit 2015 Visual Studio 2022 Nuke License MIT Build Release

Installation

Insert this configuration to enable and install the package ricaun.Revit.Mvvm in the csproj.

<ItemGroup>
    <PackageReference Include="ricaun.Revit.Mvvm" Version="*" />
</ItemGroup>

PropertyChanged.Fody

Insert this configuration to enable and install the package PropertyChanged.Fody in the csproj.

<!-- Fody -->
<ItemGroup>
    <PackageReference Include="PropertyChanged.Fody" Version="3.*" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup>
    <WeaverConfiguration >
        <Weavers>
            <PropertyChanged/>
        </Weavers>
    </WeaverConfiguration>
</PropertyGroup>

Features

IRelayCommand & IAsyncRelayCommand

public IRelayCommand Command { get; }
public IAsyncRelayCommand AsyncCommand { get; }

RelayCommand & RelayCommand

Command = new RelayCommand(() =>
{
    // Execute something
});
Command = new RelayCommand<string>((text) =>
{
    // Execute something with text
});

AsyncRelayCommand & AsyncRelayCommand

AsyncCommand = new AsyncRelayCommand(async () =>
{
    // Execute something async
    await Task.Delay(1000);
});
AsyncCommand = new AsyncRelayCommand<string>(async (text) =>
{
    // Execute something async with text
    await Task.Delay(1000);
});

ExceptionHandler

Command.ExceptionHandler += (ex) => { Console.WriteLine(ex); };

// or

Command = new RelayCommand(() =>
{
    // Execute something
}).SetExceptionHandler((ex) => { Console.WriteLine(ex); });

Release

License

This project is licensed under the MIT Licence.


Do you like this project? Please star this project on GitHub!

About

Mvvm for Revit with RelayCommand and ObservableObject to use with PropertyChanged.Fody package.

Resources

License

Stars

Watchers

Forks