Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF RichTextBox TextChanged gets called when Page initialises

$
0
0

I have a WPF RichTextBox and when the user types something into it I want to detect this and call a function.

The function checks all the other controls on my Page to see if they are all selected and then activates a NEXT button. (I'm building a questionaire)

The problem I'm having is that when the Page initialises when my program starts up, the RichTextBox TextChanged event is called and other controls (ComboBoxes) are not yet initialised and the program bombs out.

private void RichTextBox_DescribeProblem_TextChanged(object sender, TextChangedEventArgs e)
    {
        ActivateNextIcon();
    }

    private void ActivateNextIcon()
    {
        ComboBoxItem OperatingSystem = (ComboBoxItem)Combo_OS.SelectedItem;
        ComboBoxItem Version         = (ComboBoxItem)Combo_Version.SelectedItem;

        TextRange textRangeDetailedSteps = new TextRange(RichTextBox_DescribeProblem.Document.ContentStart, RichTextBox_DescribeProblem.Document.ContentEnd);
        int detailedStepsLength = textRangeDetailedSteps.Text.Length;

        if (YesNo_Permission.Selected == true && OperatingSystem != null && Version != null && YesNo_HardwareKey.Selected == true && YesNo_ExceededConnections.Selected == true && detailedStepsLength > 0)
        {
            Image_Forward.IsEnabled = true;
        }
    }
How can I stop the TextChanged event from getting called on start up?? Or how can I handle this situation?


Viewing all articles
Browse latest Browse all 18858

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>