<WebBrowser x:Name="messageBufferWebBrowser" controls:WebBrowserUtility.Body="{Binding MessageBuilder}"/>
I use this class to enable binding to the body of a 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); } } } }
What is my WebBrowser, I bind it to the StringBuilder property in the ViewModel. How can I make the WebBrowser control scroll to the end?
source share