我有一个ListBox,我希望ListBox项目的每个项目都显示在一个单独的WebBrowser中,我知道这听起来不错,但我必须这样做。 所以这是我的部分代码来解释我正在尝试做的事情:
<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>
如何将ListBox中的数据绑定到Webbrowser? 我见过很多人都在搜索这个,但我还没有找到答案! 真的很感谢你的帮助!
答案 0 :(得分:2)
使用WebBrowser是一个坏主意。如果您需要使用HTML格式显示一些文本,请使用MSP Toolkit中的HTMLTextBox或HTMLViewer(http://msptoolkit.codeplex.com/)