'Why does my WebBrowser element in WPF only show the content after calling a MessageBox?

So I have a program that contains text boxes. With these TextBox contents I can change data in the HTML of my web browser element. It all works so far.

However, when I start the program, it loads all the TextBox data correctly into the WebBrowser element. However, the web browser does not show an image, only when I output a message box in the MainWindow constructor does it also give me the correct image in the web browser element.

Here is my constructor, the data like "Offer" is the data that belongs in the TextBoxes, which also works like this:

 public MainWindow(string Angebot,string Server1, string Server2, 
        string Zubehoere, string Zubehoer2, string Netz, string Netz2, string Netz3, string Netz4)
    {
        InitializeComponent();

        //MessageBox.Show("1");
        newsView.platzhalter.Pos1_title_1 = Angebot;
        
    }

For this "newsView.platzhalter.Pos1_title_1" is my property of my binding to a TextBox.

Without MessageBox: Without

With MessageBox is the html there:

small excerpt

However, as soon as my TextChange event triggers, the web browser updates and displays everything correctly with the correct data, TextChange Event Execute this Method:

 public void replaceHTML()
    {
        _html2 = _HTMLOriginal;

        PropertyInfo[] propertiesNewsletter = platzhalter.GetType().GetProperties();
        foreach (PropertyInfo property in propertiesNewsletter)
        {
            //MessageBox.Show(property.GetValue(platzhalter, null).ToString());
            _html2 = _html2.Replace("[" + property.Name + "]", property.GetValue(platzhalter, null).ToString());
        }
        NotifyPropertyChanged(nameof(Html2));
    }

And here my ViewModel Konstuktur:

platzhalter = new NewsPlatzhalter();
        _HTMLOriginal = File.ReadAllText(@"C:\newsletter.html");
        _html2 = _HTMLOriginal;
        replaceHTML();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source