Merge branch 'master' into jimwilcox/xamlislands-wrappers-squished-restored
This commit is contained in:
Коммит
4dd7ba60de
|
@ -35,18 +35,18 @@ namespace Microsoft.Toolkit.Win32.UI.XamlHost
|
||||||
|
|
||||||
systemType = FindBuiltInType(xamlTypeName);
|
systemType = FindBuiltInType(xamlTypeName);
|
||||||
|
|
||||||
if (xamlType != null)
|
|
||||||
{
|
|
||||||
// Create custom UWP XAML type
|
|
||||||
return (Windows.UI.Xaml.FrameworkElement)xamlType.ActivateInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (systemType != null)
|
if (systemType != null)
|
||||||
{
|
{
|
||||||
// Create built-in UWP XAML type
|
// Create built-in UWP XAML type
|
||||||
return (Windows.UI.Xaml.FrameworkElement)Activator.CreateInstance(systemType);
|
return (Windows.UI.Xaml.FrameworkElement)Activator.CreateInstance(systemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xamlType != null)
|
||||||
|
{
|
||||||
|
// Create custom UWP XAML type
|
||||||
|
return (Windows.UI.Xaml.FrameworkElement)xamlType.ActivateInstance();
|
||||||
|
}
|
||||||
|
|
||||||
throw new InvalidOperationException("Microsoft.Windows.Interop.UWPTypeFactory: Could not create type: " + xamlTypeName);
|
throw new InvalidOperationException("Microsoft.Windows.Interop.UWPTypeFactory: Could not create type: " + xamlTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace Microsoft.Toolkit.Wpf.UI.Controls
|
||||||
nameof(Source),
|
nameof(Source),
|
||||||
typeof(Uri),
|
typeof(Uri),
|
||||||
typeof(WebView),
|
typeof(WebView),
|
||||||
new PropertyMetadata(WebViewDefaults.AboutBlankUri, PropertyChangedCallback));
|
new FrameworkPropertyMetadata(WebViewDefaults.AboutBlankUri, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal, PropertyChangedCallback));
|
||||||
|
|
||||||
private WebViewControlProcess _process;
|
private WebViewControlProcess _process;
|
||||||
|
|
||||||
|
@ -475,8 +475,24 @@ namespace Microsoft.Toolkit.Wpf.UI.Controls
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Uri Source
|
public Uri Source
|
||||||
{
|
{
|
||||||
get => (Uri)GetValue(SourceProperty);
|
get
|
||||||
set => SetValue(SourceProperty, value);
|
{
|
||||||
|
VerifyAccess();
|
||||||
|
return _initializationState == InitializationState.IsInitialized
|
||||||
|
? _webViewControl?.Source
|
||||||
|
: (Uri)GetValue(SourceProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
VerifyAccess();
|
||||||
|
SetValue(SourceProperty, value);
|
||||||
|
|
||||||
|
if (_initializationState == InitializationState.IsInitialized)
|
||||||
|
{
|
||||||
|
Navigate(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -646,7 +662,14 @@ namespace Microsoft.Toolkit.Wpf.UI.Controls
|
||||||
VerifyAccess();
|
VerifyAccess();
|
||||||
|
|
||||||
// TODO: Support for pack://
|
// TODO: Support for pack://
|
||||||
Source = source;
|
do
|
||||||
|
{
|
||||||
|
Dispatcher.CurrentDispatcher.DoEvents();
|
||||||
|
}
|
||||||
|
while (!_initializationComplete.WaitOne(InitializationBlockingTime));
|
||||||
|
|
||||||
|
Verify.IsNotNull(_webViewControl);
|
||||||
|
_webViewControl.Navigate(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -883,14 +906,7 @@ namespace Microsoft.Toolkit.Wpf.UI.Controls
|
||||||
// Dependency properties may be set in XAML, which would cause entry here; however,
|
// Dependency properties may be set in XAML, which would cause entry here; however,
|
||||||
// control is initialized asynchronously and may not be completed as of yet. The settings
|
// control is initialized asynchronously and may not be completed as of yet. The settings
|
||||||
// are then read by initialization and state transferred
|
// are then read by initialization and state transferred
|
||||||
if (dependencyPropertyChangedEventArgs.Property.Name == nameof(Source))
|
if (dependencyPropertyChangedEventArgs.Property.Name == nameof(IsIndexedDBEnabled))
|
||||||
{
|
|
||||||
if (wv.WebViewControlInitialized)
|
|
||||||
{
|
|
||||||
wv._webViewControl.Navigate(dependencyPropertyChangedEventArgs.NewValue as Uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (dependencyPropertyChangedEventArgs.Property.Name == nameof(IsIndexedDBEnabled))
|
|
||||||
{
|
{
|
||||||
if (wv.WebViewControlInitialized)
|
if (wv.WebViewControlInitialized)
|
||||||
{
|
{
|
||||||
|
@ -1033,6 +1049,11 @@ namespace Microsoft.Toolkit.Wpf.UI.Controls
|
||||||
|
|
||||||
private void OnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs args)
|
private void OnNavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs args)
|
||||||
{
|
{
|
||||||
|
VerifyAccess();
|
||||||
|
Dispatcher.Invoke(
|
||||||
|
() => { SetCurrentValue(SourceProperty, args.Uri); },
|
||||||
|
DispatcherPriority.DataBind);
|
||||||
|
|
||||||
// We could have used
|
// We could have used
|
||||||
// if (NavigationCompleted != null) NavigationCompleted(this, args);
|
// if (NavigationCompleted != null) NavigationCompleted(this, args);
|
||||||
// However, if there is a subscriber and the moment the null check and the call to
|
// However, if there is a subscriber and the moment the null check and the call to
|
||||||
|
@ -1048,6 +1069,8 @@ namespace Microsoft.Toolkit.Wpf.UI.Controls
|
||||||
|
|
||||||
private void OnNavigationStarting(object sender, WebViewControlNavigationStartingEventArgs args)
|
private void OnNavigationStarting(object sender, WebViewControlNavigationStartingEventArgs args)
|
||||||
{
|
{
|
||||||
|
VerifyAccess();
|
||||||
|
|
||||||
var handler = NavigationStarting;
|
var handler = NavigationStarting;
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,5 +86,22 @@ namespace Microsoft.Toolkit.Wpf.UI.XamlHost
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override System.IntPtr WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)
|
||||||
|
{
|
||||||
|
const int WM_GETOBJECT = 0x003D;
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
// We don't want HwndHost to handle the WM_GETOBJECT.
|
||||||
|
// Instead we want to let the HwndIslandSite's WndProc get it
|
||||||
|
// So return handled = false and don't let the base class do
|
||||||
|
// anything on that message.
|
||||||
|
case WM_GETOBJECT:
|
||||||
|
handled = false;
|
||||||
|
return System.IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче