|
Rank: Member Groups: Member
Joined: 10/25/2016 Posts: 10
|
I'm trying to change the URL in my application upon initialization -- instead of defining the URL with in the .xaml with <eo:WebView Url="http://myurl.com"></eo:WebView> I'd like to set it in the MainWindow.xaml.cs with by using myWebView.url = "http://myurl.com". However, according to the WinForms documentation on the matter, I need to grab a handle on the window prior to being able to set the URL. That doesn't seem to be an option with WPF. Is there anyway I can dynamically set the URL using a similar process with WPF?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
You can just set it in the code by setting the WebView's Url property. I am not sure what you meant by "grab a handle". Can you explain?
Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/25/2016 Posts: 10
|
Sorry for the lack of clarity. My end goal is being able to launch the WPF application via the command line with an argument that points to the URL I want to reach, such as "C:\wpf.exe" -http://google.com. It looks like you might be able to connect to a window handle when using Winforms like in this link, but there doesn't seem to be a comparable way to change the URL when using WPF. It seems like once it's set in the WebView's Url property it is no longer modifiable -- is this true?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
You do it the same way as you do with anything else in WPF: You just give it an ID (such as "webView1") and then modify its property through that ID. How would you modify a Button's text in WPF when the button is declared in XAML? It's exactly the same way. This is basic WPF coding that really doesn't have anything particular with EO.WebBrowser.
|
|
Rank: Member Groups: Member
Joined: 10/25/2016 Posts: 10
|
Okay, thanks for the help, needless to say I am a novice with WPF. I've tried getting and setting that property to no avail before posting this question with this.eoWebBrowser.WebView.Url = "http://myurl.com" but it is only getting/setting an empty string. I'll continue reading up on WPF basics and will probably get to the bottom of this.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, We have updated our documentation to include sample code: https://www.essentialobjects.com/doc/webbrowser/start/wpf.aspxThanks!
|
|
Rank: Member Groups: Member
Joined: 10/25/2016 Posts: 10
|
Great, thank you, I appreciate it!
|
|