简体   繁体   中英

How do I dynamically turn on/off tooltips for a WPF DataGrid in the code behind?

Is there a way to dynamically turn on/off tooltips for a WPF DataGrid in the C# code behind?

Thanks.

You could add/remove the Style programmatically:

Style style;
private void Button_AddOrRemove_Click(object sender, RoutedEventArgs e)
{
    if (dataGrid1.Resources.Count > 0)
    {
        style = dataGrid1.Resources[typeof(DataGridCell)] as Style;
        dataGrid1.Resources.Clear();
    }
    else if (style != null)
    {
        dataGrid1.Resources.Add(typeof(DataGridCell), style);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM