Welcome Guest Search | Active Topics | Sign In | Register

Dynamically changing URL when using EO.Webbrowser with WPF application Options
asbolton
Posted: Tuesday, October 25, 2016 12:12:12 PM
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?
eo_support
Posted: Tuesday, October 25, 2016 12:49:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
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!
asbolton
Posted: Tuesday, October 25, 2016 2:28:13 PM
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?
eo_support
Posted: Tuesday, October 25, 2016 2:35:36 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
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.
asbolton
Posted: Tuesday, October 25, 2016 2:52:33 PM
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.
eo_support
Posted: Wednesday, October 26, 2016 9:02:07 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

We have updated our documentation to include sample code:

https://www.essentialobjects.com/doc/webbrowser/start/wpf.aspx

Thanks!
asbolton
Posted: Wednesday, October 26, 2016 10:17:50 AM
Rank: Member
Groups: Member

Joined: 10/25/2016
Posts: 10
Great, thank you, I appreciate it!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.