I have a hyperlink in a WBA which is hosted in an IFrame. The hyperlink is pointing to an HTML page. When I click on it, an error is raised right before the WBA exists and the browser is redirected to the HTML page.
The error is here:
http://www.valil.com/AmazonBookInfo/error.jpg
I have created a sample project to recreate the error:
http://www.valil.com/AmazonBookInfo/TestHyperlinkIFrame.zip
(double-click on index.html from bin\Debug and then click on the hyperlink)
The error shows up only if the WBA is in the IFrame - if it is loaded by itself it works OK.
Thank you,
Valentin Iliescu

Error - hyperlink in a WBA in an IFrame
lvance
Can you try my Amazon ads ( http://www.valil.com/winfx/ads.html ) to see if you get the error It happens when you click on a book link and the browser is redirected to Amazon's website.
Thank you,
Valentin
viperjason
Thank you,
Valentin
Francy
Valentin
Tamoxifeno
To clarify what I have tried:
1. First variant:
MyHyperlink.xaml.cs
public partial class MyHyperlink : Hyperlink{
public MyHyperlink(){InitializeComponent();}
protected override void OnMouseEnter(MouseEventArgs e){}
protected override void OnMouseLeave(MouseEventArgs e){}
}
MyHyperlink.xaml:
<Hyperlink x:Class="MyNamespace.MyHyperlink"
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"/>
2. Second variant:
MyHyperlink.cs
public class MyHyperlink : Hyperlink
{
protected override void OnMouseEnter (MouseEventArgs e) { }
protected override void OnMouseLeave(MouseEventArgs e) { }
}
In both cases the control has been referenced like this:
< Mapping XmlNamespace="controls" ClrNamespace="MyNamespace" >
<StackPanel ... xmlns:c="controls" ... >
<TextBlock >
<c:MyHyperlink x:Name="titleLabel" NavigateUri=""/>
</TextBlock>
It seems like subclassing Hyperlink makes the code to request Unrestricted=true for UIPermission
CarlM
I did as you have said but know there is another problem - now I get this error when I run the WBA:
"Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
It is because of subclassing Hyperlink, I did it like this:
C#:
public partial class MyHyperlink : Hyperlink{
public MyHyperlink()
{
InitializeComponent();
}
protected override void OnMouseEnter(MouseEventArgs e){}
protected override void OnMouseLeave(MouseEventArgs e){}
}
XAML:
<Hyperlink x:Class="Valil.AmazonBook.VisualElements.MyHyperlink"
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"/>
Sri Dendi
patti_nyl
I was not able to repro with PDC bits on IE7. (Both your Amazon app and the test repro succeeded.) Are you on IE6 or IE7 < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks,
Karen
milTash
Giusy Provvidenti
Oh, you have attempted to use the "code-behind" model, but I think it is available only for select root-level elements. Here is how to define and use your derived class:
namespace MyNamespace
{
public class MyHyperlink : Hyperlink
{
protected override void OnMouseEnter System.Windows.Input.MouseEventArgs e)
{
}
protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
{
}
};
}
In the XAML file:
< Mapping XmlNamespace="my_namespace" ClrNamespace="MyNamespace" >
<TextBlock xmlns:my="my_namespace">
<my:MyHyperlink NavigateUri="...">Go to Start Page</my:MyHyperlink>
</TextBlock>
The Mapping and xmlns declarations can be in a higher scope. See the 'Custom Components' SDK topic for more explanation of this pattern.
ini686
Awkward workaround (until Beta 2), if you really need it: Derive a class from Hyperlink that simply overrides OnMouseEnter() and OnMouseLeave() and doesn't call the base-class implementation. Use this class in your XAML definition instead. (You'll need a < Mapping > processing instruction. See example in the 'Custom Components' SDK topic.) The idea is to disable showing the hyperlink's target in the status bar, which is what leads to the failure you reported.

Good luck.
[This posting is provided "AS IS" with no warranties, and confers no rights.]
Aleniko
Try moving the mouse away from the hyperlink as soon as you click it. If that prevents the error, it may suggest a possible workaround for your code.
Thanks again for reporting the problem and doing it in such detail.