Daniel Gomez Rico
Daniel Gomez Rico

Reputation: 15946

HyperLink in DataGrid: InvalidOperationException

I'm trying to add RichTextBoxes into the cells of a DataGrid. The RichTextBox contains a Hyperlink, but when I click it, it throws the following exception:

'Invalid Operation Exception - Reference is not a valid visual DependencyObject'

Why is this happening?

Upvotes: 1

Views: 393

Answers (1)

innopal
innopal

Reputation: 58

I would say don't use Hyperlink and use HyperlinkButton instead. Something like this:

    var hyperLink = new InlineUIContainer
    {
        Child = new HyperlinkButton
        {
            NavigateUri = myUri,
            TargetName = "_blank",
            Content = myText                                                
        }
    };

Upvotes: 1

Related Questions