Created
July 29, 2012 02:55
-
-
Save kharasoft/3195861 to your computer and use it in GitHub Desktop.
Attached Property to set the HTML Source of a WebView control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebClientHelper : DependencyObject | |
{ | |
public static readonly DependencyProperty HtmlProperty = | |
DependencyProperty.RegisterAttached("Html", typeof(string), typeof(WebClientHelper), new PropertyMetadata(null, HtmlChanged)); | |
public static void SetHtml(DependencyObject obj, string value) | |
{ | |
obj.SetValue(HtmlProperty, value); | |
} | |
public static string GetHtml(DependencyObject obj) | |
{ | |
return (string)obj.GetValue(HtmlProperty); | |
} | |
private static void HtmlChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
var webView = d as WebView; | |
if (webView == null) | |
return; | |
webView.NavigateToString((string)e.NewValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment