Remaining hint for checking on TabControl

I have a problem with TabControl , a TextBox and ToolTip validation.

Imagine you have a TabControl with two TabItems. The first element has a simple TextBox . This TextBox Text property is tied to the string property of UserControl itself with Mode=TwoWay and ValidatesOnExceptions=True . The installer of this Text property throws an exception whenever something is set.

The Resources UserControl section contains a new default style for TextBox and ToolTip checks (these styles and templates, however, are taken from MSDN ).

Now enter something into the TextBox and let the ToolTip confirm:

enter image description here

Then go to the second tab. The hint to check remains:

enter image description here

I created a VS solution containing a Silverlight application that demonstrates the problem. The VS zip archive is available here .

Has anyone had a similar problem or even a solution for this problem?

Denial of responsibility. There is the same question, https://stackoverflow.com/a/312616/2128/ , regarding Silverlight 4, which has been unanswered since about a year and a half. I have already posted this question on silverlight.net , but have not received any answers for several days.

+6
source share
2 answers

I think this is a bug in the implementation of TabControl . I applied this behavior to fix this in our application:

 public class TabControlFixBehavior: Behavior<TabControl> { protected override void OnAttached() { AssociatedObject.SelectionChanged += AssociatedObjectOnSelectionChanged; base.OnAttached(); } protected override void OnDetaching() { AssociatedObject.SelectionChanged -= AssociatedObjectOnSelectionChanged; base.OnDetaching(); } private void AssociatedObjectOnSelectionChanged(object sender, SelectionChangedEventArgs args) { if (args.RemovedItems.Count > 0) { var oldTabItem = args.RemovedItems[0] as TabItem; if (oldTabItem != null) { var popups = VisualTreeHelper.GetOpenPopups(); foreach (var popup in popups) { var toolTip = popup.Child as ToolTip; if (toolTip != null) { if (VisualTreeHelper.GetRoot(toolTip.PlacementTarget) == oldTabItem.Content) { popup.IsOpen = false; } } } } } } } 
+3
source

validation tooltip is an implicit function in silverlight 5. Clear the "UserControl.Resources" node in the user control of the "main page" and you will have the expected behavior.

[EDIT] I did not read the end of your question, sorry :)

0
source

Source: https://habr.com/ru/post/920342/


All Articles