Page 1 of 1

[SOLVED] Possible to render HTML ?

Posted: Wed May 25, 2016 10:41 am
by rkmore
I have a WCF service that returns a report in the form of an HTML snippet (nothing fancy, just a few tables).

Is there any simple way to render the returned HTML in a control or on the page?

If so could you show a quick example?

Thanks....

RKM

Re: Possible to render HTML ?

Posted: Fri May 27, 2016 5:21 am
by rkmore
This works, but I would like to have something cleverer

Code: Select all

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string html = "<body>This is a new window!</body></html>";

            CSHTML5.Interop.ExecuteJavaScript(
@"var oNewWin = window.open(""about:blank"", ""Report"", ""height=150,width=300,top=10,left=10,resizable=yes"");
oNewWin.document.open();
oNewWin.document.write(""<html><head><title>New Window</title></head>"");
oNewWin.document.write($0);
oNewWin.document.close();", html);
        }

HTML at runtime [SOLVED]

Posted: Fri Jun 03, 2016 3:14 am
by rkmore
It turns out to be pretty easy once you figure it all out. In this example a have a StackPanel named stackPanel1 where I want to display the HTML dynamically at run time

Code: Select all

    <StackPanel>
        <Button Content="Show HTML" Background="White" FontSize="22" Click="Button_Click" />
        <StackPanel x:Name="stackPanel1" />
    </StackPanel>


The following will preform this task

Code: Select all

        public class HtmlWrapper : Windows.UI.Xaml.Controls.Control
        {
            public HtmlWrapper(string pHtmlToRender)
            {
                CSharpXamlForHtml5.DomManagement.SetHtmlRepresentation(this, pHtmlToRender);
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string html = "<table><tr><td>This</td><td>is</td></tr><tr><td>a</td><td>test</td></tr></table>";
            stackPanel1.Children.Clear();
            stackPanel1.Children.Add(new HtmlWrapper(html));
        }

Re: Possible to render HTML ? [SOLVED]

Posted: Tue Aug 09, 2016 1:17 am
by Sesztak
Dear rkmore,
first of all thanks for your kind help.

It's great for more or less 'static' content.

We have a lot of property what we have to set/get dinamically by runtime + hierarchical UI structures :(
-so: it is definitely possible to do that theoretically with above-mentioned way,
but practically for our use case: it tremendous extra job.

Thanks again,
Best Regards,
Péter

Re: Possible to render HTML ? [SOLVED]

Posted: Tue Nov 22, 2016 6:36 am
by JS-Support @Userware
The new Beta 10.5 will include the "HtmlPresenter" control for displaying any arbitrary HTML content. Please feel free to let us know if you would like some specific features in this new control.

Thanks.
Regards,
JS-Support

Re: Possible to render HTML ? [SOLVED]

Posted: Wed Nov 23, 2016 12:49 am
by MichaelHughes
You tantalizingly mention 10.5....any estimates of the eta please

Thanks

Re: Possible to render HTML ? [SOLVED]

Posted: Wed Nov 23, 2016 1:45 am
by JS-Support @Userware
MichaelHughes wrote:You tantalizingly mention 10.5....any estimates of the eta please


Within 15 days :-)

Re: Possible to render HTML ? [SOLVED]

Posted: Tue Nov 29, 2016 6:01 am
by zemorango
Hi Js-Support,
You guys are doing some fantastic work, just keep it coming :),
do you have any prevision for localizable resx (resources)? :roll:


Regards

zemorango

Re: Possible to render HTML ? [SOLVED]

Posted: Mon Dec 05, 2016 2:19 am
by JS-Support @Userware
Hi,

The "HtmlPresenter" control (for displaying any arbitrary HTML content) is now available in Beta 10.5, which you can download from:

http://forums.cshtml5.com/viewforum.php?f=6

zemorango wrote:do you have any prevision for localizable resx (resources)?

Localizable Resx is expected in the first half of 2017.

Regards,
JS-Support

Re: [SOLVED] Possible to render HTML ?

Posted: Mon Dec 12, 2016 6:13 pm
by Henrygo
Hi,

How to use the HtmlPresenter?
Please provide an example,thanks.

Re: [SOLVED] Possible to render HTML ?

Posted: Tue Dec 13, 2016 2:23 am
by JS-Support @Userware
Henrygo wrote:How to use the HtmlPresenter?
Please provide an example,thanks.

Hi,
Here is an example in XAML:

Code: Select all

<Page
    x:Class="Application1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:native="clr-namespace:CSHTML5.Native.Html.Controls;assembly=CSharpXamlForHtml5">
    <Border>
        <native:HtmlPresenter Html="&lt;canvas id=&quot;demo_canvas&quot; Style=&quot;width:100%;height:100%&quot; /&gt;"/>
    </Border>
</Page>

Alternatively, you can use C#, like this: MyHtmlPresenter1.Html = @"<div />";
Regards,
JS-Support