.net 如何在代码隐藏中动态打开/关闭WPF DataGrid的工具提示?

.net 如何在代码隐藏中动态打开/关闭WPF DataGrid的工具提示?,.net,wpf,wpfdatagrid,.net,Wpf,Wpfdatagrid,在C#代码隐藏中是否有一种方法可以动态打开/关闭WPF DataGrid的工具提示 谢谢。您可以通过编程方式添加/删除样式: Style style; private void Button_AddOrRemove_Click(object sender, RoutedEventArgs e) { if (dataGrid1.Resources.Count > 0) { style = dataGrid1.Resources[typeof(DataGridC

在C#代码隐藏中是否有一种方法可以动态打开/关闭WPF DataGrid的工具提示


谢谢。

您可以通过编程方式添加/删除
样式:

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);
    }
}

在哪里以及如何设置工具提示?我在DataGrid资源中设置了XAML:那么您希望何时禁用工具提示?在什么情况下?请参阅我的答案,了解如何启用和禁用工具提示的示例。完美,Thx用于响应。