Opened Event On Tooltip Assigning dynamic content caues exception.

When I try to assign some dynamic content to the tooltip it causes an error. I using the 'opened' event on the tooltip is this the correct way to assign dynamic content?

<h3>My Syncfusion Tooltip Test</h3>
<ul>
    @foreach (var peep in people)
    {
        Person person = peep;
        <SfTooltip Opened="@(a=> ToolTipOpened(a,person))" Content="@myContent">
            <li>@peep.Name</li>
        </SfTooltip>
    }
</ul>
@code {
    string myContent = "";
    void ToolTipOpened(TooltipEventArgs args, Person peep)
    {
        myContent = peep.Name;
    }
    public class Person
    {
        public int Age { get; set; }
        public string Name { get; set; }
    }

    public List<Person> people { get; set; }
    protected override void OnInitialized()
    {
        base.OnInitialized();
        people = new List<Person>
    {
            new Person
            {
                Name ="Jennifer Eccles",
                Age =50
            },
            new Person
            {
                Name = "Carrianne",
                Age =30
            }
        };
    }
}


1 Reply 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team August 28, 2020 09:17 AM UTC

Hi Paul stanley, 
 
Greetings from Syncfusion support. 
 
We have provided a title attribute support for Tooltip component. When you declare the title attribute for list items, it takes the corresponding value as a content of Tooltip component. In that case, there is no need to change the content on Tooltip events. 
 
Refer the below code snippet. 
 
<h3>My Syncfusion Tooltip Test</h3> 
<ul> 
    @foreach (var peep in people) 
    { 
        Person person = peep; 
        <SfTooltip Target=".target"> 
            <li class="target" @attributes="@peep.htmlAttribute">@peep.Name</li> 
        </SfTooltip> 
    } 
</ul> 
@code { 
    
    public class Person 
    { 
        public int Age { get; set; } 
        public string Name { get; set; } 
        public Dictionary<string, object> htmlAttribute { get; set; } 
    } 
 
    public List<Person> people { get; set; } 
    protected override void OnInitialized() 
    { 
        base.OnInitialized(); 
        people = new List<Person> 
         { 
            new Person 
            { 
                Name ="Jennifer Eccles", 
                Age =50, 
                htmlAttribute = new Dictionary<string, object>() { { "title", "Jennifer Eccles" } } 
            }, 
            new Person 
            { 
                Name = "Carrianne", 
                Age =30, 
                htmlAttribute = new Dictionary<string, object>() { { "title", "Carrianne" } } 
            } 
        }; 
    } 
} 
 
 
Refer the sample link below. 
 
 
Refer to the below link to know ore about the Tooltip component. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 


Marked as answer
Loader.
Up arrow icon