我正在尝试在 Windows Store 应用程序的 FlipView 控件中打开一个网站。这是我的代码:
protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
var template = flipView.ItemTemplate;
var grid = (Grid)template.LoadContent();
var webView = (WebView)grid.Children[0];
webView.Navigate(new Uri("http://www.google.com"));
}
private void contentView_LoadCompleted_1(object sender, NavigationEventArgs e)
{
var template = flipView.ItemTemplate;
var grid = (Grid)template.LoadContent();
var webView = (WebView)grid.Children[0];
webView.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
和 XAML:
<FlipView
x:Name="flipView"
AutomationProperties.AutomationId="ItemsFlipView"
AutomationProperties.Name="Item Details"
TabIndex="1"
Grid.RowSpan="2"
ItemsSource="{Binding Source={StaticResource itemsViewSource}}">
<FlipView.ItemContainerStyle>
<Style TargetType="FlipViewItem">
<Setter Property="Margin" Value="0,137,0,0"/>
</Style>
</FlipView.ItemContainerStyle>
<FlipView.ItemTemplate>
<DataTemplate>
<Grid x:Name="Output">
<WebView x:Name="WebView1" Visibility="Collapsed" LoadCompleted="contentView_LoadCompleted_1"/>
<Rectangle x:Name="BlockingRect"/>
</Grid>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
也许有人早些时候遇到过这个问题?解决方案是什么?