CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
383 stars 89 forks source link

WebViewCompatible needs public void Navigate(Uri requestUri, HttpMethod httpMethod, string content = null, IEnumerable<KeyValuePair<string, string>> headers = null); #23

Open meshawn opened 5 years ago

meshawn commented 5 years ago

I'm submitting a...

Feature request (UserVoice request: )

Current behavior

This method is missing

Expected behavior

Have the ability to call WebViewCompatible.Navigate(Uri requestUri, HttpMethod httpMethod, string content = null, IEnumerable<KeyValuePair<string, string>> headers = null);

Environment

Nuget Package(s): 

Package Version(s): 

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [X] Insider Build (build number:  (18282)

App min and target version:
- [ ] Fall Creators Update (16299)
- [X] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] Insider Build (xxxxx)

Device form factor:
- [X] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [X] 2017 Preview (version: )
meshawn commented 5 years ago

Having this method would be nice, but a work around is casting the view. Feel free to close this one.

usselite commented 5 years ago

@meshawn how did you do this? Did it work with earlier windows versions? E.g. Win 7?

meshawn commented 5 years ago

You just need to cast the web view to WebBrowser: WebBrowser ie = webViewCompatible.View as WebBrowser; ie.Navigate(uri, null, null, string.Format("User-Agent: {0}\r\n", agent));

andrewkittredge commented 5 years ago

Casting to WebBrowser does not work for me.

private Microsoft.Toolkit.Wpf.UI.Controls.WebViewCompatible webViewCompatible1;
var ie = webViewCompatible1.View as System.Windows.Forms.WebBrowser;;

does not compile with Cannot convert type 'System.Windows.FrameworkElement' to 'System.Windows.Forms.WebBrowser' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion

andrewkittredge commented 5 years ago

Casting to WebBrowser does not work for me.

private Microsoft.Toolkit.Wpf.UI.Controls.WebViewCompatible webViewCompatible1;
var ie = webViewCompatible1.View as System.Windows.Forms.WebBrowser;;

does not compile with Cannot convert type 'System.Windows.FrameworkElement' to 'System.Windows.Forms.WebBrowser' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion

I figured it out. I was using Microsoft.Toolkit.Wpf.UI.Controls.WebView instead of Microsoft.Toolkit.Forms.UI.Controls.WebView.