Bars.Mvvm.FluidApi.Generator
0.1.0-beta-gdde6f755ec
This package has been replaced with Bars.Mvvm.FluentApi.Generator (Fluent instead of Fluid), which name uses more accurate terminology. Sorry for the inconvenience.
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
<PackageReference Include="Bars.Mvvm.FluidApi.Generator" Version="0.1.0-beta-gdde6f755ec"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Bars.Mvvm.FluidApi.Generator" Version="0.1.0-beta-gdde6f755ec" />
<PackageReference Include="Bars.Mvvm.FluidApi.Generator"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Bars.Mvvm.FluidApi.Generator --version 0.1.0-beta-gdde6f755ec
#r "nuget: Bars.Mvvm.FluidApi.Generator, 0.1.0-beta-gdde6f755ec"
#:package Bars.Mvvm.FluidApi.Generator@0.1.0-beta-gdde6f755ec
#addin nuget:?package=Bars.Mvvm.FluidApi.Generator&version=0.1.0-beta-gdde6f755ec&prerelease
#tool nuget:?package=Bars.Mvvm.FluidApi.Generator&version=0.1.0-beta-gdde6f755ec&prerelease
Bars.Mvvm.FluidApi.Generator
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 | Versions 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. |
-
.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.
Version | Downloads | Last Updated | |
---|---|---|---|
0.2.0 | 498 | 7/20/2025 | |
0.2.0-beta-g679861b472 | 298 | 7/9/2025 | |
0.1.0-beta-gfcd64127e5 | 299 | 7/9/2025 | |
0.1.0-beta-gdde6f755ec | 292 | 7/7/2025 | |
0.1.0-beta-ga4ce0fd211 | 284 | 7/7/2025 | |
0.1.0-beta-g6b4b9644ed | 291 | 7/8/2025 | |
0.1.0-beta-g01dd66cf1f | 234 | 6/27/2025 |