TeklaPluginWPFViewModelToolkit 1.0.0

dotnet add package TeklaPluginWPFViewModelToolkit --version 1.0.0
                    
NuGet\Install-Package TeklaPluginWPFViewModelToolkit -Version 1.0.0
                    
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="TeklaPluginWPFViewModelToolkit" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TeklaPluginWPFViewModelToolkit" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TeklaPluginWPFViewModelToolkit" />
                    
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 TeklaPluginWPFViewModelToolkit --version 1.0.0
                    
#r "nuget: TeklaPluginWPFViewModelToolkit, 1.0.0"
                    
#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 TeklaPluginWPFViewModelToolkit@1.0.0
                    
#: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=TeklaPluginWPFViewModelToolkit&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TeklaPluginWPFViewModelToolkit&version=1.0.0
                    
Install as a Cake Tool

MPD.TeklaWPFViewModelToolkit

by Main Part Design LTD

Use single template class to generate code for most of your plugin data model and view model and have a typesafe way of binding it in xaml.

Notice: This package is an independent development and is not affiliated with, sponsored by, or endorsed by Trimble Inc. "Tekla" and "Tekla Structures" are registered trademarks of Trimble Inc.

Prerequisites: This package references the Tekla.Structures.* NuGet packages provided by Trimble. This package does not include Trimble's proprietary binaries. To use this package, you must have a valid license for Tekla Structures and the necessary Tekla NuGet packages installed in your environment. Use of those dependencies is governed by the Trimble End User License Agreement (EULA).

Usage

  1. Install nuget package.

  2. Add using statement.

using MPD.TeklaWPFViewModelToolkit;

3.Add the TemplateToGenerate attribute to the class which fields you want to be used in your plugin data model and view model. Since classes are partial - you can implement custom logic alongside the template.

// This attribute is filtered by source generator
// and classes should be created based on its arguments.
[TemplateToGenerate("PluginModel", nameof(ViewModel))]
class ModelTemplate
{
    string text;
    int num1 = 1;
    double num2, num3;
}

public partial class ViewModel : IYourCustomInterface
{
    // Implement custom logic here.
}
  1. You can wire up plugin data model and view model now. Gererated classes are easy to view and debug.
[Plugin("WPFPlugin")]
[PluginUserInterface("WPFPlugin.MainWindow")]
public class WPFPlugin : PluginBase
{
    // Generated class here.
    private PluginModel _data;

    public WPFPlugin(PluginModel data)
    {
        _data = data;
    }

    public override bool Run(List<InputDefinition> Input)
    {
        // Properties will return value from initializer if Tekla will pass default value into plugin.
        var count = _data.Num1
        // Plugin Logic here.
    }
  1. In the plugin's xaml window add this line for a type safety:
<tsd:PluginWindowBase
    x:Class="WPFPlugin.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    ... important attributes are below ...
    xmlns:toolkit="clr-namespace:MPD.TeklaWPFViewModelToolkit;assembly=MPD.TeklaWPFViewModelToolkit"
    d:DataContext="{d:DesignInstance Type=local:ViewModel, IsDesignTimeCreatable=True}"
    >
  1. Now in the xaml you can use typesafe binding with components TeklaFilterCheckBoxWithInput and TeklaLabelCheckBoxWithInput.
<StackPanel Orientation="Horizontal">
    <Label
        x:Name="RegularLabel"
        Width="100"
        Height="30"
        Content="{tsd:Loc albl_Text}" />
    <toolkit:TeklaFilterCheckBoxWithInput
        x:Name="ItsWithoutBuiltinLabel"
        Property="{Binding Text}"
        Width="150"
        Height="30"
        />
</StackPanel>
<toolkit:TeklaLabelCheckBoxWithInput
    x:Name="WillHavePropertyNameAsLabel"
    Property="{Binding Num1}"
    LabelWidth="100"
    Width="250"
    Height="30"
    />

<toolkit:TeklaLabelCheckBoxWithInput
    x:Name="HasOverwrittenLabelValue"
    LabelContent="{tsd:Loc albl_Num2}"
    Property="{Binding Num2}"
    Width="250"
    Height="30"
    />

Additional Features

Attribute ViewModelTypeOverride<T> allows to change type of your ViewModel properties. Attribute UseInitializerValueOutsideRange allows to set range for the variable, otside which PluginModel property will return the initializer value.

[TemplateToGenerate("MyPluginModel", "MyViewModel")]
class ModelTemplate
{
    // Here double is used in MyViewModel.Num1 over default Distance type.
    [ViewModelTypeOverride<Tekla.Structures.Datatype.Double>]
    double num1 = 1.0

    // This attribute allows to rewrite Getter for MyPluginModel.Num2 property.
    // Tekla values outside this range in the property are replaced with initializer value (1).
    [UseInitializerValueOutsideRange(0.1, 10)]
    int num2 = 1;

    // For string value range is checked against string length.
    // Emty string or '0' from tekla will return "Steel_Undefined" from MyPluginModel.Material.
    [UseInitializerValueOutsideRange(2, 15)]
    string material = "Steel_Undefined";
}
Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • 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
1.0.0 126 1/30/2026