【发布时间】:2012-10-24 23:20:18
【问题描述】:
可能重复:
How to access NavigateToString property of a WebView in a ListView
我有一个项目列表,每个项目都使用 DataTemplate。在这个模板中,我有一个从 API 调用中获取的静态 HTML 的 Web 视图。 DataTemplate 类似如下:
<DataTemplate x:Name="DetailedPostTemplate">
<Grid Height="600" Width="600">
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="6*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="{Binding Score}"/>
<TextBlock Text="Votes" />
</StackPanel>
<Grid Grid.Column="1">
<TextBlock Text="{Binding OwnerName}" />
</Grid>
</Grid>
<!-- HTML Content Row -->
<Grid Grid.Row="1">
<WebView DataContext="{Binding Body}"/> <!-- What do I do HERE? -->
</Grid>
</Grid>
</DataTemplate>
我所能找到的,将数据“传递”到 Webview 是使用 NavigateToString 方法,但由于我不知道列表中的项目数量,我正在使用一个模板,我不能从 C# 方面调用它。如何使用 XAML 模板将此 HTML 连接到 WebView?
【问题讨论】:
标签: c# xaml data-binding windows-8