From dd7a518ea66404024cc81e927bddae1417cec421 Mon Sep 17 00:00:00 2001 From: zhangyazhou Date: Wed, 7 Dec 2022 11:37:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9wpf=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=94=AF=E6=8C=81=E6=89=A7=E8=A1=8Cjs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CefSharp.MinimalExample.Wpf/App.xaml.cs | 12 +++ .../CefSharp.MinimalExample.Wpf.csproj | 5 ++ CefSharp.MinimalExample.Wpf/MainWindow.xaml | 79 +++++++++++++------ .../MainWindow.xaml.cs | 57 +++++++++++++ CefSharp.MinimalExample.Wpf/packages.config | 1 + 5 files changed, 128 insertions(+), 26 deletions(-) diff --git a/CefSharp.MinimalExample.Wpf/App.xaml.cs b/CefSharp.MinimalExample.Wpf/App.xaml.cs index 1668715..a516982 100644 --- a/CefSharp.MinimalExample.Wpf/App.xaml.cs +++ b/CefSharp.MinimalExample.Wpf/App.xaml.cs @@ -40,5 +40,17 @@ namespace CefSharp.MinimalExample.Wpf Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); } } + + public static void RunUIThread(Action action) + { + if (Current.CheckAccess()) + { + action?.Invoke(); + } + else + { + Current.Dispatcher.BeginInvoke(action); + } + } } } diff --git a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj index e389f60..c5fa7e3 100644 --- a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj +++ b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj @@ -103,12 +103,17 @@ ..\packages\CefSharp.Wpf.107.1.120\lib\net452\CefSharp.Wpf.dll True + + ..\packages\log4net.2.0.15\lib\net45\log4net.dll + ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll + + 4.0 diff --git a/CefSharp.MinimalExample.Wpf/MainWindow.xaml b/CefSharp.MinimalExample.Wpf/MainWindow.xaml index e0d7b2c..cc63a66 100644 --- a/CefSharp.MinimalExample.Wpf/MainWindow.xaml +++ b/CefSharp.MinimalExample.Wpf/MainWindow.xaml @@ -1,13 +1,13 @@  + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" + xmlns:cef="clr-namespace:CefSharp;assembly=CefSharp.Core" + xmlns:behaviours="clr-namespace:CefSharp.MinimalExample.Wpf.Behaviours" + xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors" + Title="{Binding Path=Title, ElementName=Browser, Converter={StaticResource TitleConverter}}" + FocusManager.FocusedElement="{Binding ElementName=Browser}" + WindowState="Maximized"> @@ -23,6 +23,10 @@ + + + + @@ -30,32 +34,52 @@ -