Ruben
Ruben

Reputation: 699

Get WebBrowsers parent control

Ive been trying to get the parent of this WebBrowser control. Somehow i can't seem to find the right way of getting the parent. i thought it would work like this :

private void webtabItem1_Navigated(object sender, NavigationEventArgs e)
{
    WebBrowser Webr = (WebBrowser) sender;
    CloseableTabItem Tab = (CloseableTabItem) Webr.Parent);
    Tab.Header = e.Uri.Host;
}

It gives the error "Only assignment, call, increment, decrement, and new object expressions can be used as a statement" on .Parent. MSDN tells you can only access it as a object i tried but it doesn't seem to work.

I could get the child of the tab by means of .Content

WebBrowser Webr = (WebBrowser)Tab.Content;

It's probably not that hard just some stupid mistake of me.

Upvotes: 0

Views: 268

Answers (1)

Grant Thomas
Grant Thomas

Reputation: 45083

The error is due to an extra parenthesis after Parent, try:

CloseableTabItem Tab = (CloseableTabItem)Webr.Parent;

Upvotes: 4

Related Questions