├── .editorconfig ├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── CefSharp.Wpf.HwndHost.Example ├── App.config ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── Behaviours │ ├── HoverLinkBehaviour.cs │ └── TextBoxBindingUpdateOnEnterBehaviour.cs ├── CefSharp.Wpf.HwndHost.Example.csproj ├── Converter │ ├── EnvironmentConverter.cs │ └── TitleConverter.cs ├── Handlers │ └── DisplayHandler.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── TabbedMainWindow.xaml ├── TabbedMainWindow.xaml.cs ├── app.manifest └── crash_reporter.cfg ├── CefSharp.Wpf.HwndHost.sln ├── CefSharp.Wpf.HwndHost ├── CefSettings.cs ├── CefSharp.Wpf.HwndHost.csproj ├── ChromiumWebBrowser.cs ├── FocusHandler.cs ├── Handler │ └── IntegratedMessageLoopBrowserProcessHandler.cs ├── IWpfWebBrowser.cs └── Internals │ ├── DelegateCommand.cs │ └── NoCloseLifespanHandler.cs ├── CefSharp.snk ├── LICENSE ├── NuGet.config ├── README.md └── appveyor.yml /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | # Mostly based on https://github.com/dotnet/corefx/blob/master/.editorconfig 3 | # References 4 | # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017 5 | # https://kent-boogaart.com/blog/editorconfig-reference-for-c-developers 6 | 7 | # top-most EditorConfig file 8 | root = true 9 | 10 | # Default settings: 11 | # A newline ending every file 12 | # Use 4 spaces as indentation 13 | [*] 14 | insert_final_newline = true 15 | indent_style = space 16 | indent_size = 4 17 | charset = utf-8 18 | end_of_line = crlf 19 | trim_trailing_whitespace = true 20 | 21 | # Powershell files (build.ps1) 22 | [*.ps1] 23 | charset = utf-8-bom 24 | 25 | # Xml config files 26 | [*.{props,targets,config,nuspec,manifest}] 27 | indent_size = 2 28 | 29 | # Javascript Files 30 | [*.js] 31 | curly_bracket_next_line = true 32 | indent_brace_style = Allman 33 | 34 | # C++ Files 35 | [*.{cpp,h,in}] 36 | curly_bracket_next_line = true 37 | indent_brace_style = Allman 38 | 39 | [*.cs] 40 | # Capitalization styles 41 | dotnet_naming_style.constant_field_case_style.capitalization = pascal_case 42 | dotnet_naming_style.property_case_style.capitalization = pascal_case 43 | dotnet_naming_style.static_field_case_style.capitalization = pascal_case 44 | dotnet_naming_style.private_internal_field_case_style.capitalization = camel_case 45 | 46 | # New line preferences 47 | csharp_new_line_before_open_brace = all 48 | csharp_new_line_before_else = true 49 | csharp_new_line_before_catch = true 50 | csharp_new_line_before_finally = true 51 | csharp_new_line_before_members_in_object_initializers = true 52 | csharp_new_line_before_members_in_anonymous_types = true 53 | csharp_new_line_between_query_expression_clauses = true 54 | 55 | # Indentation preferences 56 | csharp_indent_block_contents = true 57 | csharp_indent_braces = false 58 | csharp_indent_case_contents = true 59 | csharp_indent_case_contents_when_block = false 60 | csharp_indent_switch_labels = true 61 | csharp_indent_labels = one_less_than_current 62 | 63 | # this. 64 | dotnet_style_qualification_for_field = false : suggestion 65 | dotnet_style_qualification_for_property = false : suggestion 66 | dotnet_style_qualification_for_method = false : suggestion 67 | dotnet_style_qualification_for_event = false : suggestion 68 | 69 | # Prefer using var 70 | csharp_style_var_for_built_in_types = true : none 71 | csharp_style_var_when_type_is_apparent = true : suggestion 72 | csharp_style_var_elsewhere = true : suggestion 73 | 74 | # use language keywords instead of BCL types 75 | dotnet_style_predefined_type_for_locals_parameters_members = true : suggestion 76 | dotnet_style_predefined_type_for_member_access = true : suggestion 77 | 78 | # Constant fields 79 | dotnet_naming_rule.constant_field_style.severity = error 80 | dotnet_naming_rule.constant_field_style.symbols = constant_field_target 81 | dotnet_naming_rule.constant_field_style.style = constant_field_case_style 82 | 83 | dotnet_naming_symbols.constant_field_target.applicable_kinds = field 84 | dotnet_naming_symbols.constant_field_target.required_modifiers = const 85 | 86 | # Properties 87 | dotnet_naming_rule.property_style.severity = error 88 | dotnet_naming_rule.property_style.symbols = property_target 89 | dotnet_naming_rule.property_style.style = property_case_style 90 | 91 | dotnet_naming_symbols.property_target.applicable_kinds = property 92 | dotnet_naming_symbols.property_target.required_modifiers = * 93 | 94 | # Static fields 95 | dotnet_naming_rule.static_field_style.severity = error 96 | dotnet_naming_rule.static_field_style.symbols = static_field_target 97 | dotnet_naming_rule.static_field_style.style = static_field_case_style 98 | 99 | dotnet_naming_symbols.static_field_target.applicable_kinds = field 100 | dotnet_naming_symbols.static_field_target.required_modifiers = static 101 | 102 | # Private and internal fields 103 | dotnet_naming_rule.private_internal_field_style.severity = error 104 | dotnet_naming_rule.private_internal_field_style.symbols = private_internal_field_target 105 | dotnet_naming_rule.private_internal_field_style.style = private_internal_field_case_style 106 | 107 | dotnet_naming_symbols.private_internal_field_target.applicable_kinds = field 108 | dotnet_naming_symbols.private_internal_field_target.applicable_accessibilities = private, internal 109 | 110 | # Code style defaults 111 | dotnet_sort_system_directives_first = true 112 | csharp_preserve_single_line_blocks = true 113 | csharp_prefer_braces = true 114 | csharp_preserve_single_line_statements = false 115 | dotnet_style_prefer_auto_properties = true : suggestion 116 | 117 | # Expression-level preferences 118 | dotnet_style_object_initializer = true : suggestion 119 | dotnet_style_collection_initializer = true : suggestion 120 | dotnet_style_explicit_tuple_names = false : suggestion 121 | dotnet_style_coalesce_expression = false : suggestion 122 | dotnet_style_null_propagation = false : suggestion 123 | 124 | # Expression-bodied members 125 | csharp_style_expression_bodied_methods = false : none 126 | csharp_style_expression_bodied_constructors = false : none 127 | csharp_style_expression_bodied_operators = false : none 128 | csharp_style_expression_bodied_properties = false : none 129 | csharp_style_expression_bodied_indexers = false : none 130 | csharp_style_expression_bodied_accessors = false : none 131 | 132 | # Space preferences 133 | csharp_space_after_cast = false 134 | csharp_space_after_colon_in_inheritance_clause = true 135 | csharp_space_after_comma = true 136 | csharp_space_after_dot = false 137 | csharp_space_after_keywords_in_control_flow_statements = true 138 | csharp_space_after_semicolon_in_for_statement = true 139 | csharp_space_around_binary_operators = before_and_after 140 | csharp_space_around_declaration_statements = do_not_ignore 141 | csharp_space_before_colon_in_inheritance_clause = true 142 | csharp_space_before_comma = false 143 | csharp_space_before_dot = false 144 | csharp_space_before_open_square_brackets = false 145 | csharp_space_before_semicolon_in_for_statement = false 146 | csharp_space_between_empty_square_brackets = false 147 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 148 | csharp_space_between_method_call_name_and_opening_parenthesis = false 149 | csharp_space_between_method_call_parameter_list_parentheses = false 150 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 151 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 152 | csharp_space_between_method_declaration_parameter_list_parentheses = false 153 | csharp_space_between_parentheses = false 154 | csharp_space_between_square_brackets = false 155 | 156 | # Modifier order 157 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async : error 158 | 159 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | # github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | # patreon: # Replace with a single Patreon username 5 | # open_collective: # Replace with a single Open Collective username 6 | # ko_fi: # Replace with a single Ko-fi username 7 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | # liberapay: # Replace with a single Liberapay username 10 | # issuehunt: # Replace with a single IssueHunt username 11 | # otechie: # Replace with a single Otechie username 12 | # lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | # custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | 15 | github: amaitland 16 | custom: https://paypal.me/AlexMaitland 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 The CefSharp Authors. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 4 | 5 | using System; 6 | using System.IO; 7 | using System.Windows; 8 | using CefSharp.Wpf.HwndHost.Handler; 9 | 10 | namespace CefSharp.Wpf.HwndHost.Example 11 | { 12 | /// 13 | /// Interaction logic for App.xaml 14 | /// 15 | public partial class App : Application 16 | { 17 | public App() 18 | { 19 | #if !NETCOREAPP3_1 20 | CefRuntime.SubscribeAnyCpuAssemblyResolver(); 21 | #endif 22 | } 23 | 24 | protected override void OnStartup(StartupEventArgs e) 25 | { 26 | var settings = new CefSettings() 27 | { 28 | //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data 29 | CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache") 30 | }; 31 | 32 | //Example of setting a command line argument 33 | //Enables WebRTC 34 | // - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access 35 | // - CEF Doesn't currently support displaying a UI for media access permissions 36 | // 37 | //NOTE: WebRTC Device Id's aren't persisted as they are in Chrome see https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart 38 | settings.CefCommandLineArgs.Add("enable-media-stream"); 39 | //https://peter.sh/experiments/chromium-command-line-switches/#use-fake-ui-for-media-stream 40 | settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream"); 41 | //For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180) 42 | settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing"); 43 | 44 | //See https://github.com/cefsharp/CefSharp/wiki/General-Usage#multithreadedmessageloop 45 | //The default is true 46 | const bool multiThreadedMessageLoop = true; 47 | 48 | IBrowserProcessHandler browserProcessHandler = null; 49 | 50 | if(!multiThreadedMessageLoop) 51 | { 52 | settings.MultiThreadedMessageLoop = false; 53 | browserProcessHandler = new IntegratedMessageLoopBrowserProcessHandler(Dispatcher); 54 | } 55 | 56 | // Make sure you set performDependencyCheck false 57 | Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: browserProcessHandler); 58 | 59 | base.OnStartup(e); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 The CefSharp Authors. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 4 | 5 | using System.Windows; 6 | 7 | [assembly: ThemeInfo( 8 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 9 | //(used if a resource is not found in the page, 10 | // or application resource dictionaries) 11 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 12 | //(used if a resource is not found in the page, 13 | // app, or any theme specific resource dictionaries) 14 | )] 15 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/Behaviours/HoverLinkBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System; 3 | using Microsoft.Xaml.Behaviors; 4 | 5 | namespace CefSharp.Wpf.HwndHost.Example.Behaviours 6 | { 7 | public class HoverLinkBehaviour : Behavior 8 | { 9 | // Using a DependencyProperty as the backing store for HoverLink. This enables animation, styling, binding, etc... 10 | public static readonly DependencyProperty HoverLinkProperty = DependencyProperty.Register("HoverLink", typeof(string), typeof(HoverLinkBehaviour), new PropertyMetadata(string.Empty)); 11 | 12 | public string HoverLink 13 | { 14 | get { return (string)GetValue(HoverLinkProperty); } 15 | set { SetValue(HoverLinkProperty, value); } 16 | } 17 | 18 | protected override void OnAttached() 19 | { 20 | AssociatedObject.StatusMessage += OnStatusMessageChanged; 21 | } 22 | 23 | protected override void OnDetaching() 24 | { 25 | AssociatedObject.StatusMessage -= OnStatusMessageChanged; 26 | } 27 | 28 | private void OnStatusMessageChanged(object sender, StatusMessageEventArgs e) 29 | { 30 | var chromiumWebBrowser = sender as ChromiumWebBrowser; 31 | chromiumWebBrowser.Dispatcher.BeginInvoke((Action)(() => HoverLink = e.Value)); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/Behaviours/TextBoxBindingUpdateOnEnterBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using System.Windows.Input; 3 | using Microsoft.Xaml.Behaviors; 4 | 5 | namespace CefSharp.Wpf.HwndHost.Example.Behaviours 6 | { 7 | public class TextBoxBindingUpdateOnEnterBehaviour : Behavior 8 | { 9 | protected override void OnAttached() 10 | { 11 | AssociatedObject.KeyDown += OnTextBoxKeyDown; 12 | } 13 | 14 | protected override void OnDetaching() 15 | { 16 | AssociatedObject.KeyDown -= OnTextBoxKeyDown; 17 | } 18 | 19 | private void OnTextBoxKeyDown(object sender, KeyEventArgs e) 20 | { 21 | if (e.Key == Key.Enter) 22 | { 23 | var txtBox = sender as TextBox; 24 | txtBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/CefSharp.Wpf.HwndHost.Example.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | WinExe 4 | true 5 | netcoreapp3.1;net462 6 | CefSharp.Wpf.HwndHost.Example 7 | true 8 | CefSharp.Wpf.HwndHost.Example.App 9 | AnyCPU 10 | app.manifest 11 | 9.0 12 | 13 | 14 | 15 | win-x64 16 | false 17 | 18 | 19 | 20 | 21 | all 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | PreserveNewest 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/Converter/EnvironmentConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace CefSharp.Wpf.HwndHost.Example.Converter 6 | { 7 | public class EnvironmentConverter : IValueConverter 8 | { 9 | object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | return Environment.Is64BitProcess ? "x64" : "x86"; 12 | } 13 | 14 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | return Binding.DoNothing; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/Converter/TitleConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace CefSharp.Wpf.HwndHost.Example.Converter 6 | { 7 | public class TitleConverter : IValueConverter 8 | { 9 | object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | return "CefSharp.MinimalExample.Wpf.HwndHost - " + (value ?? "No Title Specified"); 12 | } 13 | 14 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | return Binding.DoNothing; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/Handlers/DisplayHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Media; 4 | 5 | namespace CefSharp.Wpf.HwndHost.Example.Handlers 6 | { 7 | public class DisplayHandler : CefSharp.Handler.DisplayHandler 8 | { 9 | private Border parent; 10 | private Window fullScreenWindow; 11 | 12 | protected override void OnFullscreenModeChange(IWebBrowser chromiumWebBrowser, IBrowser browser, bool fullscreen) 13 | { 14 | var webBrowser = (ChromiumWebBrowser)chromiumWebBrowser; 15 | 16 | _ = webBrowser.Dispatcher.InvokeAsync(() => 17 | { 18 | if (fullscreen) 19 | { 20 | //In this example the parent is a Border, if your parent is a different type 21 | //of control then update this code accordingly. 22 | parent = (Border)VisualTreeHelper.GetParent(webBrowser); 23 | 24 | //NOTE: If the ChromiumWebBrowser instance doesn't have a direct reference to 25 | //the DataContext in this case the BrowserTabViewModel then your bindings won't 26 | //be updated/might cause issues like the browser reloads the Url when exiting 27 | //fullscreen. 28 | parent.Child = null; 29 | 30 | fullScreenWindow = new Window 31 | { 32 | WindowStyle = WindowStyle.None, 33 | WindowState = WindowState.Maximized, 34 | Content = webBrowser 35 | }; 36 | fullScreenWindow.Loaded += (_,_) => webBrowser.Focus(); 37 | 38 | fullScreenWindow.ShowDialog(); 39 | } 40 | else 41 | { 42 | fullScreenWindow.Content = null; 43 | 44 | parent.Child = webBrowser; 45 | 46 | fullScreenWindow.Close(); 47 | fullScreenWindow = null; 48 | parent = null; 49 | } 50 | }); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /CefSharp.Wpf.HwndHost.Example/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |