Tekla plug-in WPF vs WinForms: which dialog to build

Your plug-in has no idea what its dialog looks like. PluginBase gets a StructuresData object in its constructor, and it’s the same class whether the window behind it is WinForms or WPF.

So the choice isn’t about what the plug-in can do. It’s about where you type the attribute name, and what happens when you type it wrong.

The plug-in only sees attribute names

Take a plug-in that places an embed plate in a wall panel. It needs a plate profile and an edge distance. The plug-in side is identical for both dialogs:

public class StructuresData
{
    [StructuresField("plate_profile")] public string PlateProfile;
    [StructuresField("edge_dist")]     public double EdgeDistance;   // mm, from either dialog
}

Apply or Modify stores the values under plate_profile and edge_dist, and Run() reads them from the fields. The names are the contract: 18 characters at most, string values 79. [PluginUserInterface("EmbedPlate.EmbedPlateForm")] names the dialog class, and Tekla opens whichever kind it finds. (The attribute also takes the old .inp dialog text. If you still have one of those, this post isn’t your biggest problem.)

WinForms keeps the name in the designer. WPF keeps it in the ViewModel.

A WinForms dialog inherits PluginFormBase. You drop a TextBox on the form and fill in three extra rows in the Properties window, added by the StructuresExtender. The designer writes them into Designer.cs:

this.structuresExtender.SetAttributeName(this.profileTextBox, "plate_profile");  // the Tekla name
this.structuresExtender.SetAttributeTypeName(this.profileTextBox, "String");
this.structuresExtender.SetBindPropertyName(this.profileTextBox, "Text");        // control property that holds it
this.structuresExtender.SetAttributeName(this.edgeTextBox, "edge_dist");
this.structuresExtender.SetAttributeTypeName(this.edgeTextBox, "Distance");      // working units in, mm out
this.structuresExtender.SetBindPropertyName(this.edgeTextBox, "Text");

A WPF dialog inherits PluginWindowBase. The name moves to an attribute on a ViewModel property, and the XAML binds to the C# property, never to the Tekla name:

[StructuresDialog("plate_profile", typeof(TD.String))]           // the Tekla name
public string PlateProfile
{
    get => _plateProfile;
    set { _plateProfile = value; OnPropertyChanged(); }          // Get writes here: raise it
}

[StructuresDialog("edge_dist", typeof(TD.Distance))]             // working units in, mm out
public TD.Distance EdgeDistance
{
    get => _edgeDistance;
    set { _edgeDistance = value; OnPropertyChanged(); }
}

// XAML: <TextBox Text="{Binding PlateProfile}" />

Both get the same buttons. Apply(), Modify() and Create() are protected on both base classes, so the click handlers live in the form or window class either way. Get() is public on both.

WinFormsWPF
Base classPluginFormBasePluginWindowBase
Where the attribute name livesProperties window, written into Designer.cs[StructuresDialog] on a ViewModel property
Filter checkboxA CheckBox with IsFilter setWpfFilterCheckBox AttributeName="..."
Tekla controlsProfileCatalog, SaveLoad, OkApplyModifyGetOnOffCancelThe same set with a Wpf prefix
LayoutDrag and drop, pixel positionsXAML grids that resize and grow
What your AI agent reads wellGenerated designer code it shouldn’t editPlain XAML and a ViewModel it can write in full

A name typo fails without a word, in either one

Type edge_dst in the dialog and edge_dist in StructuresData. It compiles. The dialog opens. You type 150, press Modify, and Run() reads a field that was never set, because nothing was ever stored under the name it asked for. No exception, no log line.

I’ve lost an afternoon to that. My first plug-in dialogs were WinForms, and switching to WPF didn’t fix it, because the name is still a string in two files. Neither base class checks it. In WPF it’s three places if you add a WpfFilterCheckBox. Copy the name, never retype it, and keep the list of names in one place you can read top to bottom.

Each one has its own quiet way to show stale values

WinForms: setting profileTextBox.Text = "PL20*200" from code before the dialog is shown doesn’t stick for a control with an AttributeTypeName. Tekla’s own documentation says so. Use SetAttributeValue(profileTextBox, "PL20*200") instead.

WPF: three of them, all common.

  • An auto-property ({ get; set; }) works on Apply. On Get, Tekla writes the selected embed’s values into the ViewModel, the property never raises PropertyChanged, and the box keeps showing the old number.
  • Forget DataContext = viewModel; in the window’s constructor and every binding is empty. Tekla hands you the ViewModel. It doesn’t assign it.
  • WpfProfileCatalog is a picker button, not an input. SelectedProfile="{Binding ...}" doesn’t round-trip. Bind a TextBox, and copy the value in on SelectClicked and back out on SelectionDone.

WPF has more traps. It also has fewer surprises after the first week, because the whole dialog is text you can read.

Keep the WinForms dialog that works. Build the next one in WPF.

If a WinForms dialog has run for years on your hollow-core or column plug-ins, rewriting it buys you nothing the plug-in can see. When you do port one, keep every attribute name exactly as it was. The values in models and saved attribute files are stored by those names, so the existing instances open with their values in the new dialog.

For a new plug-in, WPF. The dialog stays readable as it grows, TD.Distance handles feet-and-inches users for you, and an AI agent writes a full ViewModel and XAML far more reliably than it edits designer code. One exception goes the other way: in a macro, use System.Windows.Forms.MessageBox. Tekla’s macro compiler often doesn’t reference the WPF assemblies, and the WPF one stops with CS0234.

The short version for your next dialog

  • The plug-in only sees StructuresData. WinForms or WPF changes the dialog, not Run().
  • The attribute name is the contract: identical in every place, 18 characters at most, never checked for you.
  • WinForms: set values from code with SetAttributeValue, not .Text.
  • WPF: setters that raise PropertyChanged, DataContext assigned, catalog pickers shuttled in code-behind.
  • New plug-in: WPF. A working WinForms dialog: leave it, or port it with every name unchanged.

The agent can’t see a name mismatch either. So it checks before it hands over. The skill writes WPF dialogs by default, with an eleven-point delivery checklist where every line is a failure someone hit: the name in three places, the raising setters, the missing DataContext, the catalog pickers. Almost nothing in that list throws an error. It shows up later, as a wrong number in a dialog. In the course, you build a plug-in with a full Apply/Modify/Get dialog and read the checklist the agent ran on it.

Tekla Open API Course: build real Tekla tools with an AI agent →

Related: Debug a Tekla plug-in in Visual Studio (attach, not F5) · Tekla TSEP packaging: build a .tsep with BatchBuilder · Tekla recorded macro to Open API: what the recorder writes

Tags

Greg Olszewski

Greg Olszewski builds Tekla Open API tools: Grasshopper Tekla Drawing Link, Smart Select, Tekla Lookup. Ten years of C# on Tekla Structures, day job in precast. Now he teaches engineers to build their own.

About Greg ›

COURSE

Build your own Tekla tools

Learn the Tekla Open API in C#, from your first plug-in to tools your team actually uses.

See the course ›