In a WPF application, I have user control.
public class MyControl : Control { static MyControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(MyControl), new FrameworkPropertyMetadata(typeof(MyControl))); } public static readonly DependencyProperty ControlStatusProperty = DependencyProperty.Register("ControlStatus", typeof(int), typeof(MyControl), new PropertyMetadata(16)); public int ControlStatus { get { return (int)GetValue(ControlStatusProperty); } set { SetValue(ControlStatusProperty, value); ChangeVisualState(false); } } ... public override void OnApplyTemplate() { base.OnApplyTemplate(); ... ToolTipService.SetToolTip(this, "Status: " + ControlStatus); } private void ChangeVisualState(bool useTransitions) { ... ToolTipService.SetToolTip(this, "Status: " + ControlStatus); }
Problem: ToolTip always shows the value of the ControlStatus property that was at the time the OnApplyTemplate() method was OnApplyTemplate() .
The ControlStatus property of the custom control has been changed at run time, but ToolTip still always shows the initial value.
How can I make the Custom Control tooltip always show the current value of the Custom Control property?
source share