2012-11-05 37 views
0

可能重複:
How to access NavigateToString property of a WebView in a ListView如何將HTML綁定到DataTemplate的WebView?

我有使用一個DataTemplate對於每個呈現物品的各物品的清單。在這個模板中,我有一個來自API調用的靜態HTML Webview。該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?

回答

2

WebView沒有支持此屬性的可綁定屬性。有很多人寫了附加的屬性,允許你綁定到WPF和Silverlight WebView控件,這些應該可以在Windows 8中進行一些小的更改。例如參見this solution

相關問題