Understanding Component Bindings
A component binding connects a server-side type to a client-side UI control. The framework uses theIComponentBinding interface to define these mappings.
IComponentBinding Interface
TheIComponentBinding interface (source:UiMetadataFramework.Core/Binding/Component/IComponentBinding.cs:11) defines the contract for component bindings:
Creating Custom Input Components
Input components represent user input fields like text boxes, dropdowns, date pickers, etc.Step 1: Create the Component Attribute
First, create an attribute that extendsComponentAttribute:
GetAdditionalData() method allows you to attach custom metadata to the component.
Step 2: Create the Value Type
Create a class that will hold the component’s value:- The component attribute decorating the type
- A custom metadata factory for complex metadata generation
- Configuration attributes defining what customizations are allowed
Step 3: Register the Component
Register your component assembly with theMetadataBinder:
Creating Custom Output Components
Output components represent rendered results like tables, charts, text displays, etc.Example: Action List Component
Here’s a simple output component from UiMetadataFramework.Basic (source:UiMetadataFramework.Basic/Output/ActionList/ActionList.cs:10):Output Component Attribute
The output component attribute is similar to the input version:Component Configuration
Components can accept configuration throughComponentConfigurationAttribute classes. Use HasConfigurationAttribute to declare allowed configurations:
ConfigurationPropertyAttribute:
Best Practices
- Use meaningful component names: The component name (e.g., “dropdown”, “action-list”) must match what the client expects
- Include metadata factories for complex components: Use custom factories when you need to transform or augment the default metadata
- Document additional data: Use
GetAdditionalData()to expose component-specific metadata to clients - Keep components focused: Each component should have a single, clear responsibility
- Use configuration attributes: Make components configurable through attributes rather than hardcoding behavior
Next Steps
- Learn how to create custom metadata factories for complex components
- Understand dependency injection in UIMF
- See how to integrate with frontend clients