繁体   English   中英

如何在后面的代码中动态打开/关闭WPF DataGrid的工具提示?

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

有没有一种方法可以在后面的C#代码中为WPF DataGrid动态打开/关闭工具提示?

谢谢。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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