19 using System.Collections.Generic;
23 using System.Windows.Controls;
24 using System.Windows.Resources;
42 #region Attached property 'Html' 44 public static readonly DependencyProperty HtmlProperty =
45 DependencyProperty.RegisterAttached(
49 new UIPropertyMetadata(null, HtmlPropertyChanged));
51 public static string GetHtml(DependencyObject obj)
53 return (
string)obj.GetValue(HtmlProperty);
56 public static void SetHtml(DependencyObject obj,
string value)
58 obj.SetValue(HtmlProperty, value);
61 public static void HtmlPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
63 WebBrowser browser = o as WebBrowser;
66 browser.NavigateToString(e.NewValue as
string);
72 #region Attached property 'Stream' 74 public static readonly DependencyProperty StreamProperty =
75 DependencyProperty.RegisterAttached(
79 new UIPropertyMetadata(null, StreamPropertyChanged));
81 public static string GetStream(DependencyObject obj)
83 return (
string)obj.GetValue(StreamProperty);
86 public static void SetStream(DependencyObject obj,
string value)
88 obj.SetValue(StreamProperty, value);
91 public static void StreamPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
93 WebBrowser browser = o as WebBrowser;
96 Stream s = e.NewValue as Stream;
99 s.Seek(0, SeekOrigin.Begin);
100 browser.NavigateToStream(s);
Provides attached properties to facilitate data binding of a WebBrowser control.