@@ -327,16 +327,18 @@ within a WebView2 control using the `GetActiveMatchIndex` method.
327327public async Task<int> GetActiveMatchIndexAsync()
328328{
329329 var webViewFind = webView.CoreWebView2.FindController; // Assuming webView is your WebView2 control
330- var activeMatchIndex = await webViewFind.GetActiveMatchIndexAsync ();
330+ var activeMatchIndex = webViewFind.ActiveMatchIndex ();
331331 MessageBox.Show($"Active Match Index: {activeMatchIndex}", "Find Operation", MessageBoxButton.OK);
332332 return activeMatchIndex;
333333}
334334
335335void ActiveMatchIndexChangedSample()
336336{
337- _webview.matchCount Changed += (object sender, CoreWebView2ActiveMatchIndexChangedEventArgs args) =>
337+ webView.CoreWebView2.FindController.ActiveMatchIndexChanged += (object sender, EventArgs args) =>
338338 {
339- // Update Custom UI
339+ // Access the active match index synchronously in the event handler.
340+ int activeMatchIndex = webView.CoreWebView2.FindController.ActiveMatchIndex;
341+ // Update Custom UI based on the new active match index.
340342 };
341343}
342344//! [GetActiveMatchIndex]
@@ -504,21 +506,22 @@ namespace Microsoft.Web.WebView2.Core
504506 Backward ,
505507 };
506508
507- runtime CoreWebView2Find
509+ runtime CoreWebView2Find
510+ {
511+ [interface_name (" Microsoft.Web.WebView2.Core.ICoreWebView2Find" )]
508512 {
509- [interface_name (" Microsoft.Web.WebView2.Core.ICoreWebView2Find" )]
510- {
511- void StartFindAsync(CoreWebView2FindConfiguration configuration);
512- void FindNextAsync();
513- void FindPreviousAsync();
514- void StopFindAsync();
515- bool ShouldHighlightAllMatches { get; set; }
516- bool ShouldHighlightActiveMatch { get ; set ; }
517- bool UseCustomUI { get ; set ; }
518- int GetActiveMatchIndexAsync ();
519- int GetMatchesCountAsync ();
520- }
513+ void StartFind(CoreWebView2FindConfiguration configuration);
514+ void FindNext();
515+ void FindPrevious();
516+ void StopFind();
517+ bool ShouldHighlightAllMatches { get; set; }
518+ bool ShouldHighlightActiveMatch { get ; set ; }
519+ bool UseCustomUI { get ; set ; }
520+ int ActiveMatchIndex { get ; }; // Synchronously gets the active match index.
521+ int MatchesCount { get ; }; // Synchronously gets the matches count.
521522 }
523+ }
524+
522525
523526 runtimeclass CoreWebView2FindConfiguration {
524527 [interface_name (" Microsoft.Web.WebView2.Core.ICoreWebView2StagingFindConfiguration" )]
0 commit comments