locked
hyperlinks (barkest) - 11/19/2006 1:28 AM PST RRS feed

  • Question

  • By: barkest

    Hi,
    
    is it possible to include a hyperlink on a 3d object?
    
    or
    
    what code in c# is required to set up a hyperlink 'on click' (for a button)?
    
    thank you very much
    
    (hyperlinks should be able to be added via a panel in EID rather than 
    manually)
    Tuesday, February 19, 2008 6:26 PM

Answers

  • By: Brennon Williams
    Howdy Steve,

    You could style a lable to look like a hyperlink and add that element to
    your object. You may want to consider using the make button tool if you need
    the click functionality or use a mouse down event for other elements.

    In the back end, you want to call the Process class to start an external
    process or to launch IE and go to a given URL.

    In your code, just remember to add the following using statement:

    using System.Diagnostics;

    and then in the click handler you can do something like this:

    Process.Start("notepad", "readme.txt");

    or

    Process.Start("IExplore.exe","
    http://www.yahoo.com");

    See how you go with that...

    Cheers


    "barkest" wrote:

    Click to show or hide original message or reply text.

    Tuesday, February 19, 2008 9:49 PM

All replies

  • By: Brennon Williams
    Howdy Steve,

    You could style a lable to look like a hyperlink and add that element to
    your object. You may want to consider using the make button tool if you need
    the click functionality or use a mouse down event for other elements.

    In the back end, you want to call the Process class to start an external
    process or to launch IE and go to a given URL.

    In your code, just remember to add the following using statement:

    using System.Diagnostics;

    and then in the click handler you can do something like this:

    Process.Start("notepad", "readme.txt");

    or

    Process.Start("IExplore.exe","
    http://www.yahoo.com");

    See how you go with that...

    Cheers


    "barkest" wrote:

    Click to show or hide original message or reply text.

    Tuesday, February 19, 2008 9:49 PM
  • By: barkest
    thanks Brennon, works great. I was not aware of the system.diagnostics bit :(

    "Brennon Williams" wrote:

    Click to show or hide original message or reply text.

    Tuesday, February 19, 2008 9:49 PM
  • By: barkest


    Hi again Brennon,

    it worked fine from Test Project in EID but doesn't when deployed as an xbap?

    thanks for taking the time

    "barkest" wrote:

    Click to show or hide original message or reply text.
    Tuesday, February 19, 2008 9:51 PM
  • By: Brennon Williams
    Yes.. this is because your web server probably does not allow you the rights
    to spawn new processes, as opposed to running on your own box where you have
    all the permissions in the world.

    When looking at Hyperlinking from an XBAP there are a few thinks that need
    to be taken into consideration. Firstly, the sandbox requires that the user
    intiate a direction change which means that you can not just make the user
    navigate to a new site, you have to provide them with an object in real terms
    that has some understanding of the being activated by the user or
    programatically. It would appear that the Hyperlink class funny enough is
    about the only one that has this feature.

    You might want to have a look at the Hyperlink class, but for now you could
    try adding the following to your Markup which should give you a Hyperlink
    that will work in an XBAP when added to a FlowDocument:

    <Page ... >
    ...
    <Hyperlink NavigateUri="www.x-coders.com">
    Champion!!
    </Hyperlink>
    ...
    </Page>



    This is probably not what you want though as the Hyperlink is part of the
    System.Windows.Document class and it can not be sub-classed for security
    reasons in an internet sandbox. This means that you have two choices, you can
    provide a document on your XBAP that contains the hyperlink (Hyperlink is an
    Inline element) or you can can be real sneaky and create a derived
    ContentControl with a Textblock embedded in it. Then you could create a Style
    which uses the ContentControl and away you go, you have a Style that you can
    assign to UIElements that is XBAP hyperlinkable....

    Let me know if you really want to go down this root as it is a bit of a mess
    trying to put it together in here...

    Cheers

    "barkest" wrote:

    Click to show or hide original message or reply text.

    Tuesday, February 19, 2008 9:52 PM