You cannot add a hyperlink to the StackPanel - you will get a runtime error. (Actually, I am surprised that this is not a compile-time error.) This is because Hyperlink does not live on the "control" side of WPF using <Button> and <StackPanel> and other things that are laid out on rectangular screen fragments and go down with UIElement . Instead, it lives on the “textual” side of things, with <Bold> and <Run> and <Paragraph> and other usually texical things that carry words and flow in lines and paragraphs and are omitted from TextElement .
Once you realize that there are two separate class hierarchies with different behaviors, it makes sense that the hyperlink will be on the "text" side of things (it makes it easier, for example, to have a paragraph with a hyperlink in the middle and even so that this hyperlink wraps itself through a line break )
But no, it is not so easy to detect when you start.
To mix the two worlds and use the hyperlink as a control, all you have to do is put it in a TextBlock. TextBlock is a control (that is, it can go to the StackPanel) that contains text things (that is, it can contain a hyperlink):
<TextBlock><Hyperlink Click="buttonClose_Click">Close</Hyperlink></TextBlock>
Joe White Aug 09 '09 at 23:06 2009-08-09 23:06
source share