private void ExecuteFindClearResultCommand()
 {
     FindResult.Clear();
     if (_pdfComponent != null && _pdfComponent.IsDocumentOpened)
     {
         _pdfComponent.FindComponent.ClearFindSelections();
     }
 }
        private async void ExecuteFindCommand()
        {
            ActiveFindPage = 1;
            FindResult.Clear();
            IsFindActive = true;

            // Cancelation token not used.
            // The cancelation is implemented by the IsFindActive property
            var ct = new CancellationToken();
            await Task.Factory.StartNew(
                () =>
            {
                _pdfComponent.FindComponent.FindText(
                    FindText,
                    IsFindCaseSensitive,
                    IsFindWholeWords,
                    (pageIndex) =>
                {
                    ActiveFindPage = pageIndex + 1;
                    return(IsFindActive);
                },
                    (page) =>
                {
                    if (page != null)
                    {
                        App.Current.Dispatcher.Invoke(() =>
                        {
                            FindResult.Add(page);
                        });
                    }

                    return(IsFindActive);
                },
                    (page, position) =>
                {
                    if (page != null && position != null)
                    {
                        App.Current.Dispatcher.Invoke(() =>
                        {
                            page.Positions.Add(position);
                        });
                    }

                    return(IsFindActive);
                });
            },
                ct,
                TaskCreationOptions.LongRunning,
                TaskScheduler.Default).ConfigureAwait(false);

            IsFindActive = false;
        }