| Rank: Newbie Groups: Member
 
 Joined: 9/26/2016
 Posts: 5
 
 | 
		    I have an app that uses a Dependency property to add a data binding to webbrowser control. I am doing that to use it with the navigatetostring method. 
 Now, I am switching over to EO.webbrowser and trying to databind a LoadHtml() method. is that possible? Here's how my current setup works:
 
 <Window x:Class="Mandrill.Window.MandrillWindow"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:src="clr-namespace:Mandrill.Window"
 Title="Mandrill" Height="350" Width="525">
 <Grid>
 <WebBrowser
 src:WebBrowserHelper.Body="{Binding MyHtml}" Name="browser"
 />
 </Grid>
 </Window>
 
 
 class WebBrowserHelper
 {
 public static readonly DependencyProperty BodyProperty =
 DependencyProperty.RegisterAttached("Body", typeof(string), typeof(WebBrowserHelper), 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 = (WebBrowser)d;
 string value;
 if ((string)e.NewValue == string.Empty || (string)e.NewValue == null)
 {
 value = @"nbsp;";
 }
 else
 {
 value = (string)e.NewValue;
 }
 webBrowser.NavigateToString(value);
 }
 }
 
 | 
	| Rank: Administration Groups: Administration
 
 Joined: 5/27/2007
 Posts: 24,425
 
 | 
		    Hi,
 Have you tried to replace NavigateToString with LoadHtml?
 
 Thanks!
 | 
	| Rank: Newbie Groups: Member
 
 Joined: 9/26/2016
 Posts: 5
 
 | 
		    LoadHtml() is a method that can be called on WebView while this method casts to WebBrowser: 
 var webBrowser = (WebBrowser)d;
 
 Trying to cast to WebView results in an error that DependencyObject cannot be cast to WebView
 | 
	| Rank: Administration Groups: Administration
 
 Joined: 5/27/2007
 Posts: 24,425
 
 | 
		    Hi, There is no "WebBrowser" class in our library. We have "WebControl" and "WebView". You can get the WebView from a WebControl through this property:https://www.essentialobjects.com/doc/eo.webbrowser.wpf.webcontrol.webview.aspx Thanks!
		 | 
	| Rank: Newbie Groups: Member
 
 Joined: 9/26/2016
 Posts: 5
 
 | 
		    OK, so casting to WebControl and then extracting WebView before calling LoadHtml() seems to get the job done. 
 private static void OnBodyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
 var webBrowser = (WebControl)d;
 string value;
 if ((string)e.NewValue == string.Empty || (string)e.NewValue == null)
 {
 value = @"nbsp;";
 }
 else
 {
 value = (string)e.NewValue;
 }
 webBrowser.WebView.LoadHtml(value);
 }
 
 Now a different issue:
 
 It doesn't actually render the page properly. I have a d3.js chart that I am trying to render from a string. Do I need to do anything special to enable js?
 | 
	| Rank: Newbie Groups: Member
 
 Joined: 9/26/2016
 Posts: 5
 
 | 
		    Here's an example of a string that I am trying to render: 
 <!DOCTYPE html><html><head>
 <meta content="utf-8">
 <link rel="stylesheet" href="file:///C:/Users/ksobon/AppData/Roaming/Dynamo/Dynamo Revit/1.2/packages/Archi-lab_Mandrill/extra/bootstrap/css/bootstrap.min.css">
 <style>
 body {
 font: 10px Arial;
 }
 .axis path {
 fill: none;
 stroke: grey;
 shape-rendering: crispEdges;
 }
 .axis text {
 font-family: Arial;
 font-size: 10px;
 }
 .axis line {
 fill: none;
 stroke: grey;
 stroke-width: 1;
 shape-rendering: crispEdges;
 }
 svg{
 display: block;
 margin: auto;
 }
 
 </style>
 </head>
 <body><div class="row">
 <div class="col-md-12" id="barbarchart1" align="center">
 <script>
 function renderBarChart() {
 
 var data =  [{"name":"A","value":1},{"name":"B","value":2}];
 
 var tickValues = data.map(function (d){return d.name;});
 var step = Math.floor(tickValues.length / 3);
 var indexes = d3.range(0,tickValues.length, step);
 if (indexes.indexOf(tickValues.length - 1) == -1){
 indexes.push(tickValues.length - 1);
 }
 var tickArray = d3.permute(tickValues, indexes);
 
 var margin = { top: 40, right: 20, bottom: 30, left: 40 },
 width = 1000 - margin.left - margin.right,
 height = 500 - margin.top - margin.bottom;
 
 var x = d3.scale.ordinal()
 .domain(data.map(function (d) { return d.name; }))
 .rangeRoundBands([0, width], 0.1);
 
 var y = d3.scale.linear()
 .range([height, 0]);
 
 var xAxis = d3.svg.axis()
 .scale(x)
 .orient("bottom")
 .tickValues(tickArray);
 
 var yAxis = d3.svg.axis()
 .scale(y)
 .orient("left");
 
 var barChart = d3.select("#barbarchart1").append("svg")
 .attr("width", width + margin.left + margin.right)
 .attr("height", height + margin.top + margin.bottom)
 .append("g")
 .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
 
 y.domain([0, 5]);
 
 barChart.append("g")
 .attr("class", "x axis")
 .attr("transform", "translate(0," + height + ")")
 .call(xAxis);
 
 barChart.append("g")
 .attr("class", "y axis")
 .call(yAxis)
 .append("text")
 .attr("transform", "rotate(-90)")
 .attr("y", 6)
 .attr("dy", ".71em")
 .style("text-anchor", "end")
 .text("Label");
 
 barChart.selectAll("#bar")
 .data(data)
 .enter().append("rect")
 .attr("id", "bar")
 .attr("x", function (d) { return x(d.name); })
 .attr("width", x.rangeBand())
 .attr("y", function (d) { return y(d.value); })
 .attr("fill", "#3282BE")
 .attr("height", function (d) { return height - y(d.value); })
 .on("click", function() {sortBars();})
 .on("mouseover", function(d){
 
 var xPos = parseFloat(d3.select(this).attr("x"));
 var yPos = parseFloat(d3.select(this).attr("y"));
 var height = parseFloat(d3.select(this).attr("height"));
 var width = parseFloat(d3.select(this).attr("width"));
 
 d3.select(this).attr("fill", "#FF0000");
 
 barChart.append("text")
 .attr("x",xPos)
 .attr("y", yPos - 3)
 .attr("font-family", "sans-serif")
 .attr("font-size", "10px")
 .attr("font-weight", "bold")
 .attr("fill", "black")
 .attr("text-anchor", "middle")
 .attr("id", "tooltip")
 .attr("transform", "translate(" + width/2 + ")")
 .text(d.name +": "+ d.value);
 })
 .on("mouseout", function(){
 barChart.selectAll("#tooltip").remove();
 d3.select(this).attr("fill", "#3282BE");
 });
 
 var sortOrder = true;
 
 var sortBars = function() {
 
 //Flip value of sortOrder
 sortOrder = !sortOrder;
 
 var x0 = x.domain(data.sort(sortOrder
 ? function(a, b) { return b.value - a.value; }
 : function(a, b) { return d3.ascending(a.name, b.name); })
 .map(function(d) { return d.name; }))
 .copy();
 
 barChart.selectAll("#bar")
 .sort(function(a, b) { return x0(a.name) - x0(b.name); });
 
 var transition = barChart.transition().duration(750),
 delay = function(d, i) { return i * 50; };
 
 transition.selectAll("#bar")
 .delay(delay)
 .attr("x", function(d) { return x0(d.name); });
 
 transition.select(".x.axis")
 .call(xAxis)
 .selectAll("g")
 .delay(delay);};
 
 function type(d) {
 d.value = +d.value;
 return d;
 }
 }
 renderBarChart();
 </script>
 </div>
 </div>
 
 </body></html>
 | 
	| Rank: Administration Groups: Administration
 
 Joined: 5/27/2007
 Posts: 24,425
 
 | 
		    Hi,
 This is something you will need to fix yourself. You can try to load it in a regular browser and see if it works. If that works, then it should work with EO.WebBrowser as well.
 
 Thanks!
 | 
	| Rank: Newbie Groups: Member
 
 Joined: 9/26/2016
 Posts: 5
 
 | 
		    You are right I was missing a reference to a d3 library. I also set my webbrowser options to enable js, set encoding to UTF-8 and disable web security since I am using local file references. 
 It works now. Thanks!
 | 
	| Rank: Administration Groups: Administration
 
 Joined: 5/27/2007
 Posts: 24,425
 
 | 
		    Great. Glad to hear that it works for you!
		 |