TdxCustomAdorner.TargetElementClass Property
Specifies the adorner’s target element class.
Declaration
property TargetElementClass: TdxAdornerCustomTargetElementClass read; write;
Property Value
Type | Description |
---|---|
TdxAdornerCustomTargetElementClass | The reference to the target UI element class. |
Remarks
The TargetElementClass
property value specifies the target UI element type accessible through the TargetElement property. You can assign the following class-references to the TargetElementClass
property to switch between available UI element targets for the adorner:
- TdxAdornerTargetElementControl
- Allows you to anchor the adorner to a control on the parent form.
- TdxAdornerTargetElementPath
- Allows you to anchor the adorner to UI elements that belong to other controls and components.
Code Examples
Display UI Badges for All Hamburger Menu Groups
You can use badges to mark or highlight individual UI elements in your application.
The following code example creates UI badges for all groups in a Navigation Bar control and configures badge appearance and position settings:
var
I: Integer;
ABadge: TdxBadge;
AElementPath: TdxAdornerTargetElementPath;
begin
dxUIAdornerManager1.BeginUpdate; // Initiates the following batch change
try
for I := 0 to dxNavBar1.Groups.Count - 1 do // Iterates through all navigation bar groups
begin
ABadge := dxUIAdornerManager1.Badges.Add; // Creates a badge for the corresponding group
ABadge.Text := IntToStr(I); // Uses the group index as the badge caption
// Associate the created badge with the corresponding navigation bar group
ABadge.TargetElementClass := TdxAdornerTargetElementPath;
AElementPath := ABadge.TargetElement as TdxAdornerTargetElementPath;
AElementPath.Path := dxNavBar1.Name + '.' + dxNavBar1.Groups[I].Name;
end;
dxUIAdornerManager1.Badges.Active := True; // Displays created badges
finally
dxUIAdornerManager1.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
Create and Position a UI Element Badge
The following code example creates a badge and moves it up by 5
pixels and right by 50
pixels:
var
ABadge: TdxBadge;
AElementControl: TdxAdornerTargetElementControl;
begin
dxUIAdornerManager1.BeginUpdate; // Initiates the following batch change
try
ABadge := dxUIAdornerManager1.Badges.Add; // Creates a badge
ABadge.Text := 'Prints the Report'; // Specifies the badge's caption
ABadge.Offset.X := 50; // Moves the badge right by 50 pixels from the base position
ABadge.Offset.Y := -5; // Moves the badge up by 5 pixels from the base position
// Customize the appearance of the created badge
ABadge.Background.Color := clLime;
ABadge.Font.Style := [fsBold];
ABadge.Font.Color := clBlue;
// Associate the created badge with a TcxButton
ABadge.TargetElementClass := TdxAdornerTargetElementControl;
AElementControl := ABadge.TargetElement as TdxAdornerTargetElementControl;
AElementControl.Control := cxButton1; // Specifies the target button
dxUIAdornerManager1.Badges.Active := True; // Displays the created badge
finally
dxUIAdornerManager1.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
See Also