Bars.Mvvm.FluidApi.Generator 0.1.0-beta-gdde6f755ec

Suggested Alternatives

Bars.Mvvm.FluentApi.Generator

Additional Details

This package has been replaced with Bars.Mvvm.FluentApi.Generator (Fluent instead of Fluid), which name uses more accurate terminology. Sorry for the inconvenience.

This is a prerelease version of Bars.Mvvm.FluidApi.Generator.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Bars.Mvvm.FluidApi.Generator --version 0.1.0-beta-gdde6f755ec
                    
NuGet\Install-Package Bars.Mvvm.FluidApi.Generator -Version 0.1.0-beta-gdde6f755ec
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bars.Mvvm.FluidApi.Generator" Version="0.1.0-beta-gdde6f755ec">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bars.Mvvm.FluidApi.Generator" Version="0.1.0-beta-gdde6f755ec" />
                    
Directory.Packages.props
<PackageReference Include="Bars.Mvvm.FluidApi.Generator">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bars.Mvvm.FluidApi.Generator --version 0.1.0-beta-gdde6f755ec
                    
#r "nuget: Bars.Mvvm.FluidApi.Generator, 0.1.0-beta-gdde6f755ec"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bars.Mvvm.FluidApi.Generator@0.1.0-beta-gdde6f755ec
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bars.Mvvm.FluidApi.Generator&version=0.1.0-beta-gdde6f755ec&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Bars.Mvvm.FluidApi.Generator&version=0.1.0-beta-gdde6f755ec&prerelease
                    
Install as a Cake Tool

Bars.Mvvm.FluidApi.Generator

NuGet Downloads

This package generates extension methods for Actipro's WPF Bars ViewModels for building bars menu and configuring properties, providing a fluid API for creating bar menus in a more declarative way.

Features

  • Generated settings for individual properties, to allow for chaining methods in a fluid API style.
  • Convenience methods for reducing boiler plate when constructing bar menus.

Getting started

dotnet add package Bars.Mvvm.FluidApi.Generator

Pre-generated extension methods

If you wish to use pre-generated package instead, with the limitation that you will have to update the package every time Actipro adds new properties to their ViewModels and a new version of this package is available.

dotnet add package Bars.Mvvm.FluidApi.Wpf

Usage

Basic Usage

To use the fluid API, you need to register the generated extension methods in your project. This is typically done in a static class that implements IBarViewModelProvider.

iewModels.Register(BarControlKeys.AlignCenter, key
    => new BarToggleButtonViewModel(key)
        .WithCommand(setTextAlignmentCommand, TextAlignment.Center)
        .WithKeyTipText("AC")
        .WithDescription("Center content with the page."));

Convenience methods

Providing fluid API for convenience methods to set properties and construct new viewmodels.

Images

The WithImages method allows you to set all image sizes for a bar item using a registered image key. Available for all view models implementing IHasVariantImages interface and all images can be set in one call.

return new BarButtonViewModel(key)
    .WithImages(imageProvider, key);

Command and command parameters

Assign a command and its parameter in a single call using the WithCommand method. This is available for all view models that have a matching CommandParameter property, such as WithPopupOpeningCommand, WithUnmatchedTextCommand, etc.

return new BarToggleButtonViewModel(key)
    .WithCommand(setTextAlignmentCommand, TextAlignment.Center);

Tabs, Items, AboveMenuItem, etc.

Properties that are declared on the ViewModel as ObservableCollection<T>, such as RibbonTabViewModel.Groups, RibbonGroupViewModel.Items, BarComboBoxViewModel.AboveMenuItems.

Adding a batch of items

var items = new []
{
    new BarButtonViewModel("Item1"),
    new BarButtonViewModel("Item2")
};
return new BarComboBoxViewModel(key)
    .WithAboveMenuItems(items);

Or one by one

return new RibbonGroupViewModel("Group1")
    .WithItem(new BarButtonViewModel("Button1"))
    .WithItem(new BarButtonViewModel("Button2");

BarComboBoxViewModel.WithUnmatchedTextCommand

Use WithUnmatchedTextCommand to set IsUnmatchedTextAllowed and UnmatchedTextCommand in a single call.

return new BarComboBoxViewModel()
    .WithUnmatchedTextCommand(unmatchedTextCommand, true);

Simple sample

As a simple syntax example, the following code shows how to create a BarToggleButtonViewModel with a command and some additional properties using the fluid API.

Note that the WithCommand method is an extension method that allows you to set the command and its parameter in a single call. This is available for all sort of ICommand that have a matching CommandParameter property, such as WithPopupOpeningCommand, WithUnmatchedTextCommand, etc.

<details> <summary>Old syntax</summary>

Old syntax

viewModels.Register(BarControlKeys.AlignCenter, key
	=> new BarToggleButtonViewModel(key, SetTextAlignmentCommand)
	{
		KeyTipText = "AC", 
		Description = "Center content with the page.", 
		CommandParameter = TextAlignment.Center
	});

</details>

New syntax

viewModels.Register(BarControlKeys.AlignCenter, key
    => new BarToggleButtonViewModel(key)
        .WithCommand(setTextAlignmentCommand, TextAlignment.Center)
        .WithKeyTipText("AC")
        .WithDescription("Center content with the page."));

The fluid API is available as a incremental Source Generator to reduce the need to upgrade to a new package every time Actipro adds new properties to their ViewModels and then having to wait for a new version of the Fluid API NuGet package to get full support. d in Avalonia support, please let me know by creating an issue or a discussion in the repository.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.