Starting with version 15 (as of the kits from the 05.05.2022) controls can be augmented by using the xBehavior class.
This can be easily done by declaring a type inheriting from the xBehavior<T> class defined in the TimeLine.Framework.Behaviors namespace and implementing the OnAttached and OnDetaching abstrct methods.
The underlying control can be accessed through the AssociatedObject property. Here's a small example of a xBehavior that turns the background color of all xButton controls to red:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TimeLine.Client.Controls;
using TimeLine.Framework.Behaviors;
using System.Windows.Media;
namespace CustomModule1
{
public class CustomControlBehavior : xBehavior<xButton>
{
protected override void OnAttached()
{
AssociatedObject.Background = Brushes.Red;
}
protected override void OnDetaching()
{
}
}
}
In order to apply a behavior for all controls automatically, you just need to add it to the TLAppContent.xml file in your customization, as follows:
Please notice how the Behavior XML tag is declared:
The AttachedOn attribute points to the control type this behavior should be attached to
The Dll attribute points to the assembly where the custom behavior is declared in
The Class attribute points to the full name of the custom behavior's type
After performing the steps described above each time a control is initialized that matches the AttachedOn property on a declared behavior, a behavior instance will be instantiated and attached to that control automatically, calling the OnAttached method, allowing you to write custom logic for controls in your customizations.