This is a migrated thread and some comments may be shown as answers.

Another Day Another BUG!

1 Answer 32 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rashad Rivera
Top achievements
Rank 1
Rashad Rivera asked on 09 May 2012, 01:26 PM
Well yet again, I pull down the latest WPF build and find my past troubles resolved, but new ones prevail. 

OK, down to the point.  The RadGridView is buggie due to a check in the RadWatermarkTextBox.  I don't know why, but when I override a columns template and specify TextBlock elements that use Hyperlink(s), this function fails because it assumes all focusedElements are of type Visual (which Hyperlink(s) are not).  In case your wondering why im so critical here, it is because I'm constantly finding bugs.  Go figure!

Telerik's Code
private bool GetIsFocused()
{
    var focusedElement = FocusManagerHelper.GetFocusedElement(this);
    if (focusedElement != null) {
        return focusedElement == this || this.IsAncestorOf((DependencyObject)focusedElement);
    }
    return false;
}

My improvement:
private bool GetIsFocused()
{
    var focusedElement = FocusManagerHelper.GetFocusedElement(this);
    if (focusedElement != null && focusedElement is DependencyObject) {
        var focusedAsDependencyObject = (DependencyObject)focusedElement;
        if (focusedAsDependencyObject is System.Windows.Media.Visual)
            return focusedAsDependencyObject == this || this.IsAncestorOf(focusedAsDependencyObject);
        else if (focusedAsDependencyObject is FrameworkContentElement) {
            var parentVisual = ((FrameworkContentElement)focusedAsDependencyObject).Parent as System.Windows.Media.Visual;
            return focusedAsDependencyObject == this || (parentVisual != null && this.IsAncestorOf(parentVisual));
        }
    }
    return false;
}

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 14 May 2012, 12:23 PM
Hello Rashad,

Thank you for sending your improvement.

We are aware of this issue and we will consider it.  As a workaround, you can also set Focusable property of the Hyperlink to "False".

Hope this helps.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Rashad Rivera
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or