alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class AttachmentTemplateContext

    Inheritance
    object
    AttachmentTemplateContext
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Syncfusion.Blazor.InteractiveChat
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class AttachmentTemplateContext

    Constructors

    AttachmentTemplateContext()

    Declaration
    public AttachmentTemplateContext()

    Properties

    Index

    Gets or sets the zero-based index of the currently selected file used to update the preview template.

    Declaration
    public int Index { get; set; }
    Property Value
    Type Description
    int

    An int representing the index of the active file within SelectedFile. The default value is -1, which indicates that no file is selected.

    Remarks

    Use this property to synchronize which file’s details are displayed in a preview template (for example, when a user clicks a thumbnail from a list of selected files).

    Valid values range from 0 to SelectedFile.Count - 1. Values outside this range should be treated as -1 (no selection) or ignored by the component.

    When updated, the component should resolve the corresponding FileInfo from SelectedFile and refresh the bound AttachmentTemplate.

    SelectedFile

    Gets the file information for the attachment currently being rendered in a custom template.

    Declaration
    public FileInfo SelectedFile { get; set; }
    Property Value
    Type Description
    FileInfo

    The FileInfo object for the current attachment in the template's rendering context. This property is read-only and its value is determined by the parent component.

    Remarks

    This property is implicitly available as the context variable within templates such as AttachmentTemplate.

    It provides access to the attachment's metadata, including its Name, Size, and FileSource, enabling fully custom UI rendering for each attachment.

    Examples

    The following example demonstrates how to use the implicit context object within a AttachmentTemplate to create a custom layout for each selected file.

    <SfChatUI>
            <AttachmentTemplate>
                @{
                    var fileContext = context as FileInfo;
                    if (fileContext != null)
                    {
                        <div class="custom-attachment-preview">
                            <span class="file-icon">📁</span>
                            <div class="file-details">
                                <span class="file-name">@fileContext.Name</span>
                                <span class="file-size">@((fileContext.Size / 1024.0).ToString("F2")) KB</span>
                            </div>
                        </div>
                    }
                }
            </AttachmentTemplate>
    </SfChatUI>
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved