Reputation: 763
I've got a ListBox and I want each Item of the ListBox items to be displayed in a seperate WebBrowser, I know it sounds like a bad idea but I have to make it this way. So this is my partial code to explain what I'm trying to do:
<ListBox Margin="2,786,-14,-34" ItemsSource="{Binding comments}" DataContext="{Binding BindsDirectlyToSource=True}" Name="commentsListBox" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,17">
<StackPanel Width="311">
<!--<TextBlock Text="{Binding poster_username}" TextWrapping="NoWrap" Style="{StaticResource PhoneTextSubtleStyle}" TextTrimming="WordEllipsis" Width="Auto" Foreground="White" FontFamily="Segoe WP Semibold" />
<TextBlock Text="{Binding comment_text}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}" TextTrimming="WordEllipsis" MaxHeight="100" />-->
<phone:WebBrowser Source="{Binding comment_text}" HorizontalAlignment="Left" Margin="23,786,0,0" Name="commentsWebBrowser" VerticalAlignment="Top" Height="453" Width="440" DataContext="{Binding ElementName=commentsListBox}" Background="Black" Foreground="{x:Null}" OpacityMask="Black" Opacity="0" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
How do I bind between the data from the ListBox to the Webbrowser? I've seen that many people searched for this but I didn't find an answer yet! Would really appreciate your help!
Upvotes: 1
Views: 488
Reputation: 16361
Using a WebBrowser is a bad idea. If you need to show some text with HTML formatting, use HTMLTextBox or HTMLViewer from MSP Toolkit (http://msptoolkit.codeplex.com/)
Upvotes: 2