Webview in ListView ItemTemplate

2 posts, 0 answers
  1. Rodney
    Rodney avatar
    4 posts
    Member since:
    Jan 2014

    Posted 06 Nov 2018 Link to this post

    I'm getting formatted html data i need to put into a list list view. My Web view is not displaying the format HTML. It show the html in plain text.

    Here is my DataTemplate:

     <DataTemplate x:Key="ListViewItemTemplate">
                    <telerikListView:ListViewTemplateCell>
                        <telerikListView:ListViewTemplateCell.View>
                            <StackLayout Padding="20">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>

                                    <Image Grid.Column="0" Grid.Row="0" Source="{Binding UserIcon}" WidthRequest="35"/>

                                    <StackLayout Grid.Column="1" Grid.Row="0" Orientation="Vertical">
                                        <StackLayout Orientation="Horizontal">
                                            <Label Text="{Binding UiDisplayName}" FontFamily="SFProText#600"
                                     FontSize="17" FontAttributes="None" TextColor="#FF000000"/>
                                            <Label Text="{Binding UiTimeStamp}" FontFamily="SFProText#400" FontSize="15"
                                     FontAttributes="None" TextColor="#B36A767D" />
                                        </StackLayout>
                                        <Label Text="{Binding Content}" />
                                        <WebView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                                                Margin="0" Source="{Binding WebViewSource}" />
                                    </StackLayout>
                                </Grid>
                            </StackLayout>
                        </telerikListView:ListViewTemplateCell.View>
                    </telerikListView:ListViewTemplateCell>
                </DataTemplate>

     

    Any Suggestions?

  2. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1168 posts

    Posted 06 Nov 2018 Link to this post

    Hello Rodney,

    Is the property a string property? You would also get the same behavior if you are using a plain ListView or even a WebView on the page by itself. The RadListView doesn't help prepare a WebView in any special way.

    See this Microsoft documentation on how to use a web view with HTML string in memory by instantiating an HtmlWebViewSource. Once that is set up correctly, you will get the following result:

    (screenshot of WebView in RadListView)




    If you are still having trouble with using WebView and the HTML, I recommend posting this on StackOverflow or Xamarin Forums because we don't have any resources or documentation to help with plain Xamarin.Forms controls.

    I hope I was able to point you in the right direction.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top