Hyperlinks not supported

Aug 1, 2007 at 5:35 PM
If you use Hyperlinks in a WPF/CAB application you will get an assertion failed when you click the hyperlink. That is because FrameworkElementActivationService.frameworkElement_GotKeyboardFocus expects e.OriginalSource to be a FrameworkElement but an Hyperlink is not a Framework element.

I changed FrameworkElement to DependencyObject in some methods and it seems to work. But I'm not sure this change will entail problems.

private void frameworkElement_GotKeyboardFocus(object sender, RoutedEventArgs e)
{

Debug.Assert(e.OriginalSource is DependencyObject);
e.Handled = ActivateWorkItemForFrameworkElement(e.OriginalSource as DependencyObject);
}

private bool ActivateWorkItemForFrameworkElement(DependencyObject dependencyObject)
{
Debug.Assert(dependencyObject != null);
if (GetIsExempt(dependencyObject))
{
return false;
}

_workItem.Activate();
return true;
}

public static bool GetIsExempt(DependencyObject dependencyObject)
{
Guard.ArgumentNotNull(dependencyObject, "frameworkElement");

//by default, clicking on menu items will not cause the related work item to be activated
if ((dependencyObject is MenuItem) && (DependencyPropertyHelper.GetValueSource(dependencyObject, IsExemptProperty).BaseValueSource == BaseValueSource.Default))
{
return true;
}

return (bool) dependencyObject.GetValue(IsExemptProperty);
}
Coordinator
Aug 1, 2007 at 9:23 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.