Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1551
  • Last Modified:

WPF TreeView Item Hyperlink- How to create a TreeViewITem that is a hyperlink?

I have a treeview like this

Fruit
 --   Apples
      ---  Mac
      --    Jon
--   Oranges


On the Apple Node and Orange node I want to make a hyperlink that can be clicked on and navigated to a url... thanks
0
JElster
Asked:
JElster
  • 3
  • 2
1 Solution
 
grishavCommented:
You can manage this with HtmlTextBlock (as I sent you yesterday - http://www.codeproject.com/KB/WPF/htmltextblock.aspx).

But probably much simpler idea is to "fake" the hyperlink:
just make a button with usual TextBlock inside (underline the text to make it similar to standard hyperlink) and add a click handler which will open some Frame. THen you can use Navigate method of Frame class to go to the url you need.
Good luck
0
 
JElsterAuthor Commented:
Hi..
I need to create the hyperlink in code.. how can I do that?
thx
0
 
JElsterAuthor Commented:
How do i programmatically create

 <Grid>

        <TextBlock>Outside area of frame</TextBlock>

        <Frame Name="FrameWithinGrid" >

        </Frame>

        <Button Height="23" Margin="114,12,25,0"

                Name="button1" VerticalAlignment="Top" Click="button1_Click">Navigate to C# Corner

        </Button>

    </Grid>

0
 
grishavCommented:
Something like :

Grid g = new Grid();
g.Children.Add(new TextBlock("Outside area of frame"));
Frame fr = new Frame();
g.Children.Add(fr);
Button b = new Button();
g.Children.Add(b);
b.Height = 23;
b.Margin = new Margin(114,12,25,0);
b.Click += MyFunc  etc.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now