Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
How to apply tooltip to each field programatically
posted

Hi..I m using Xamdatagrid.xamgrid is having more than 20 columns.

here i gave columns labels as w1,w2,w3,w4 ....

Here i want to use tooltips for each field labels .But i want to apply in code.

Bec i ve to apply vaues like this .first field header tooltip  is 1 means second field header tooltip is 5 like tat.

third field header tooltip is 9 and so on..

we can apply in xaml using tooltipservice.tooltip="1"..it is working fine.but it is fixed..

but i want to appy in code..bec my tooltip values may change..based on the user input.it is not fixed.

so please give reply how to apply tooltip to each field in c# code.

here i = 1

mainDataGrid.DefaultFieldLayout.Fields[2].Tag = i.ToString();

Here no Tooltip property for field..Tag is not worked here.

 

Thanks in advance..

  • 69686
    Suggested Answer
    posted

    Hello,

    You can do this with the following code snippet:

    <Style TargetType="{x:Type igDP:LabelPresenter}">

    <Setter Property="ToolTip" Value=""/>

    <EventSetter Handler="FieldToolTipOpening" Event="ToolTipOpening"/>

     </Style>

    ...

    void FieldToolTipOpening(object sender, ToolTipEventArgs e)

            {

                if (sender is LabelPresenter && sender != null)

                {

                    LabelPresenter l = sender as LabelPresenter;

                    l.ToolTip = l.Field.Index.ToString() + " " + l.Field.Name.ToString();

                }

            }

    Hope this helps,

    Alex.