问题
I'm creating a web browser app and would like textbox2 (url address bar) to be in sync with webBrowser1 (web page display) so that what ever the user clicks on the page the address will appear in the box.
回答1:
You could bind textbox2.Text
to webBrowser1.Source
, as follows:
<TextBox x:Name="textbox2" Text="{Binding ElementName=webBrowser1, Path=Source}" />
<WebBrowser Height="160" Width="160" x:Name="webBrowser1"/>
That way, when the user changes the text in textBox2
, the web browser will also update the page it's pointing to.
来源:https://stackoverflow.com/questions/13962763/keep-text-box-in-sync-with-browser-location