How to use the ViewChanged event

I have seen in the documentation that there is a ViewChanged event on the file manager. But I can't figure out how to use it. I have tried like this:

<SfFileManager @ref="_filemanager" TValue="FileManagerDirectoryContent" Height="100%" @bind-View="_fileManagerView">
    <FileManagerEvents ViewChanged="MyFunc">
    </FileManagerEvents>
...
But I get an error saying that the ViewChanged property doesn't exist. Any help would be appreciated!


1 Reply

PM Prasanth Madhaiyan Syncfusion Team March 13, 2025 12:47 PM UTC

Hi Milena Stefanovic,


Greetings from Syncfusion support.


Based on the shared details, we understand that you are trying to use the ViewChanged event in the FileManager component and are facing issues. However, we would like to let you know that it's a direct property of the SfFileManager component, so you need to bind this event in the SfFileManager tag.

Additionally, we would like to inform you that the @bind-View property and the ViewChanged event are both used for the same purpose of updating the View property in the Blazor FileManager component. However, to use the View property along with the ViewChanged event, you can manually implement two-way binding for the View property, as shown in the code snippets below.

[Home.razor]

@using Syncfusion.Blazor.FileManager;

<SfFileManager @ref="_filemanager" TValue="FileManagerDirectoryContent" Height="100%" View="_fileManagerView" ViewChanged="OnViewChanged">
    <FileManagerAjaxSettings Url="https://ej2-aspcore-service.azurewebsites.net/api/FileManager/FileOperations"
    UploadUrl="https://ej2-aspcore-service.azurewebsites.net/api/FileManager/Upload"
    DownloadUrl="https://ej2-aspcore-service.azurewebsites.net/api/FileManager/Download"
    GetImageUrl="https://ej2-aspcore-service.azurewebsites.net/api/FileManager/GetImage">
    </FileManagerAjaxSettings>
</SfFileManager>

@code {
    SfFileManager<FileManagerDirectoryContent> _filemanager;
    private ViewType _fileManagerView = ViewType.Details;

    // Handle the ViewChanged event
    private void OnViewChanged(ViewType newView)
    {
        _fileManagerView = newView;

        // Perform additional actions based on the new view type
        if (_fileManagerView == ViewType.LargeIcons)
        {
            Console.WriteLine("Large Icons View Selected");
        }
        else if (_fileManagerView == ViewType.Details)
        {
            Console.WriteLine("Details View Selected");
        }
    }
}

For your reference, we have attached the sample. 

Sample: Attached as a zip file. 

Check out the attached sample and let us know if you need any further assistance.

Regards,

Prasanth Madhaiyan.


Attachment: BlazorSample_a49ea3e2.zip

Loader.
Up arrow icon