forum

Home / DeveloperSection / Forums / How do I scroll a WPF WebBrowser control to the end?

How do I scroll a WPF WebBrowser control to the end?

Anonymous User 7711 19-Jul-2013
<WebBrowser x:Name="messageBufferWebBrowser"

     controls:WebBrowserUtility.Body="{Binding MessageBuilder}"/>

I'm using this class to enable binding to the Body of the WebBrowser control

public static class WebBrowserUtility
{
    public static readonly DependencyProperty BodyProperty =
    DependencyProperty.RegisterAttached("Body", typeof(string), typeof(WebBrowserUtility), new PropertyMetadata(OnBodyChanged));
    public static string GetBody(DependencyObject dependencyObject)
    {
        return (string)dependencyObject.GetValue(BodyProperty);
    }
    public static void SetBody(DependencyObject dependencyObject, string body)
    {
        dependencyObject.SetValue(BodyProperty, body);
    }
    private static void OnBodyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var webBrowser = d as WebBrowser;
        if (!string.IsNullOrWhiteSpace(e.NewValue as string) && webBrowser != null)
        {
            if (Application.Current.MainWindow != null && !DesignerProperties.GetIsInDesignMode(Application.Current.MainWindow))
            {
                webBrowser.NavigateToString((string)e.NewValue);
            }
        }
    }
}

That's my WebBrowser, I'm binding it to a StringBuilder property on the ViewModel. How can I get the WebBrowser control to scroll to the end?


wpf wpf 
Updated on 19-Jul-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By