0
我正在從標籤屬性中檢索工具提示,如下所示,標記屬性已刷新/更正工具提示,但創建新的工具提示時,我沒有刷新一個。在鼠標懸停時,我稱之爲創建工具提示方法。有人可以解釋爲什麼我沒有在我的控制下獲得刷新的工具提示嗎?Tooltip不刷新WPF
private void CreateToolTip(Border border, RealisticControlBase control)
{
border.SetValue(ToolTipService.IsEnabledProperty, false);
if (control != null)
{
FrameworkElement tooltip = ToolTipService.GetToolTip(border) as FrameworkElement;
control.InvalidateArrange();
tooltip.InvalidateArrange();
if ((control.Tag as string) != null)
{
string templatename = control.Tag.ToString();
object abc=Application.Current.FindResource(templatename);
if ((Application.Current.FindResource(templatename) as DataTemplate) != null)
{
(tooltip as ToolTip).ContentTemplate = Application.Current.FindResource(templatename) as DataTemplate;
tooltip.DataContext = control.DataContext;
border.SetValue(ToolTipService.IsEnabledProperty, true);
(tooltip as ToolTip).Content = control.DataContext;
}
}
}
它適用於某些控件,但是當我使用某些屬性更改模板,然後在創建工具提示時未刷新 – TechGiant