Ask a questionAsk a question
 

AnswerWPF WebBrowser control child elements

  • Tuesday, November 03, 2009 6:01 AMRammohan Ammiti Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi

    How to assign the child elements to WPF Webbrowser control.

    In our windowsformhost control have a property is there

    stackpanlename.Child = webbrowsername;

     I tried in WPF same as

    stackpanlename.Datacontext = webbrowsername;

    always seems null value any property is there..


    Thanks
    Ram

    • Moved byMark Wilson-ThomasMSFTTuesday, November 03, 2009 6:48 PMWPF Platform question (From:Visual Studio WPF Designer)
    •  

Answers

  • Wednesday, November 04, 2009 9:41 AMJim Zhou - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Rammohan Ammiti,

    If I understand you correctly, you want to set a WebBrowser instance as child of StackPanel instance, right? In WPF, the DataContext property of StackPanel is used to "hold" the data, it will not automatically generate the visual representation, you can use Children property to add the child element, and call the Add method to add the child element, something like:

    stackPanel.Children.Add();

    If you still haing additional issues with this, please feel free to feed back.
    Thanks.
    Sincerely.
    Jim Zhou -MSFT

All Replies

  • Wednesday, November 04, 2009 9:41 AMJim Zhou - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Rammohan Ammiti,

    If I understand you correctly, you want to set a WebBrowser instance as child of StackPanel instance, right? In WPF, the DataContext property of StackPanel is used to "hold" the data, it will not automatically generate the visual representation, you can use Children property to add the child element, and call the Add method to add the child element, something like:

    stackPanel.Children.Add();

    If you still haing additional issues with this, please feel free to feed back.
    Thanks.
    Sincerely.
    Jim Zhou -MSFT