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
My improvement:
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
;
}