Mvvm for Revit with RelayCommand
, AsyncRelayCommand
and ObservableObject
to use with PropertyChanged.Fody package.
Insert this configuration to enable and install the package ricaun.Revit.Mvvm in the csproj
.
<ItemGroup>
<PackageReference Include="ricaun.Revit.Mvvm" Version="*" />
</ItemGroup>
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>
public IRelayCommand Command { get; }
public IAsyncRelayCommand AsyncCommand { get; }
Command = new RelayCommand(() =>
{
// Execute something
});
Command = new RelayCommand<string>((text) =>
{
// Execute something with text
});
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);
});
Command.ExceptionHandler += (ex) => { Console.WriteLine(ex); };
// or
Command = new RelayCommand(() =>
{
// Execute something
}).SetExceptionHandler((ex) => { Console.WriteLine(ex); });
This project is licensed under the MIT Licence.
Do you like this project? Please star this project on GitHub!