📘
TimeLine E3
  • TimeLine E3 Documentation
  • Framework
    • Introduction
    • DataSet Definition
    • Window Handling Object
      • Input/Output arguments
      • Open
      • BindDataControls
      • Item Changes
      • Item Search
      • MenuItemClicked
      • Print
      • ModuleOpened (BlueArrow)
      • BlueArrowArguments
      • New Row
      • Delete Row
      • Save
      • Transactions
      • Locking [deprecated]
      • Locking (new)
      • Resizing a response window
      • ParaPanel
      • Adding DMS Tab to a Module
    • BusinessObject
    • Controls
      • BindingFormat
      • LookupGrid and SearchDef
      • ComboBox
      • RadioButton
      • Multiline Textbox
      • xTextBoxSearch
      • xFileBrowse [v16+]
      • DxDispoColumn
      • DxProgressColumn
      • DxTemplateColumn
      • Change control caption programmatically
      • TabControl
      • Navigation
      • Enable controls programmatically
      • Enable a MenuItem programmatically
      • Filter search values
      • Jumping to another module
      • Messages, Notifications, Log, Exceptions, Translation
      • LoggerSink [deprecated]
      • Log
      • OpenFile, FolderBrowsing and SaveFile
      • Execute Actions while displaying an Hourglass
      • Using Progress
      • Async methods with progress bar
      • Wizard
      • Customizing controls using xBehaviors
      • TLProperty.AllowInReadOnly [v16+]
    • DataSet Operations
    • Business-related functionality
      • Getting the next primary key
      • Hybrids
      • Enums
      • Get Current User
    • SQL
    • SQL (using named parameters)
    • Advanced SQL
    • Expression Binding
    • Server-side logic & customization [v16+]
      • Service Hoster
      • Starting / stopping hosted services
      • Changes to scheduled jobs!
      • Business Object Proxies
      • Business Object API
    • Colors in Expression Bindings [v15+]
    • Theming
      • Icons
  • TimeLine Developer (TLD)
    • Debugging in TLD
    • Targets
    • Custom Project Rework [v16+]
  • TimeLine-specific LL functions
  • Stunnel proxy
    • Pre-requisites
    • 1. Initial setup
    • 2. Generate the server/web certificates
    • 3.a. Generating client certificates using the CSR flow
    • 3.b. Generate client certificates from the server console
    • 4. Setting up the E3 client connection
    • 5. Setting up the browser certificates
  • Configuration
    • Configuring the WCF timeout
  • Troubleshooting the E3 Bridge
  • [Deprecated]
    • TimeLine WEB - deprecated in v16+
      • Prerequisites for running the WASM modules on the server
      • Prerequisites for developing WASM modules with TLD
      • Creating a small web module with TLD
      • Terminal Configuration
    • Customization Examples - deprecated in v16+
    • Codestore [deprecated]
    • Configuring the scheduled jobs timeout - deprecated in v16+
Powered by GitBook
On this page
  1. Framework
  2. Controls

Customizing controls using xBehaviors

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:

<TLAppContent>
  <WindowHandlingObjects>
    <WHO ID="whoItem" DLL="CustomModule1.dll" Class="CustomModule1.wndItemCustom" Descr="" />
  </WindowHandlingObjects>
  <BusinessObjects>
    <BO ID="busArt" DLL="CustomModule1.dll" Class="CustomModule1.busArtCustom" Descr="" SyncHybridType="" />
  </BusinessObjects>
  <Modules>
    <Module ID="modItem" XAML="CustomModule1\wndItemCustom.xaml" WHO="whoItem" Title="Artikelstamm" AllowsDirectOpen="" Descr="" Uid="" />
  </Modules>
  <Reports />
  <Behaviors>
    <Behavior AttachedOn="TimeLine.Client.Controls.xButton" Dll="CustomModule1.dll" Class="CustomModule1.CustomControlBehavior" />
  </Behaviors>
</TLAppContent>

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.

PreviousWizardNextTLProperty.AllowInReadOnly [v16+]

Last updated 3 years ago