我有一个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?我已经看到很多人在搜索这个,但我还没有找到答案!会非常感谢你的帮助!
发布于 2012-07-03 21:27:13
使用WebBrowser不是一个好主意。如果需要以HTML格式显示某些文本,请使用MSP Toolkit (http://msptoolkit.codeplex.com/)中的HTMLTextBox或HTMLViewer。
https://stackoverflow.com/questions/11310560
复制相似问题