2012-02-28 12 views
-1

WebBrowserで初めて情報を読み込もうとすると、ページが切り取られ、2回目に情報がうまく表示されます。Webブラウザコントロールでページ全体が表示されませんか?

または、例えば、向きが肖像ある、と私は風景に回すとバック​​すべてが表示され肖像画に行くとき..

これは私が使用するコードです。

private void Default_Loaded(object sender, RoutedEventArgs e) 
    { 
     // Only need to reset web page when creating a new info page (coming from Info index or tombstoned app): 
     if (_newPageInstance && (NavigationContext.QueryString.Count >= 1)) 
     { 
      // Set html page for web browser control based on park and page # passed in: 
      if (_parkId.Length <= 0) 
      { 
       _parkId = App.MapModel.InfoParkId; // App.ViewModel.CurrentPark.ParkId might not be ready if tombstoned 
       _parkPage = Convert.ToInt32(NavigationContext.QueryString.Values.First()); 
       SubTitle.Text = App.MapModel.InfoPageTitle; // set title like "Legend" for this page 
      } 
      // else - these 3 values were set during OnNavigatedTo when returning from tombstoning 
      // 
      Browser.Base = Constants.ParkInfoDirectory; // "ParkInfo" folder 
      string s = string.Format("{0}/section_{1}.html", _parkId, _parkPage); // URL = "/ParkInfo/ti217/5" for page 5 of Rainier 

      Browser.Navigate(new Uri(s, UriKind.Relative)); 

      //Browser.Navigate(new Uri(s, UriKind.Relative)); 
     } 

     //var myHeight = this.ActualHeight; 

     //Browser.Height = ((StackPanel)Browser.Parent).ActualHeight; 

     this.Browser.UpdateLayout(); 

     this.ContentPanel.UpdateLayout(); 
    } 

    // Executes when the user navigates to this page (or coming back from being tombstoned): 
    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
    { 
     base.OnNavigatedTo(e); 
     if (ParkMaps.App.ViewModel.CurrentPark != null) 
     { 
      // Set title bar to use this park's name: 
      PageTitle.Text = ParkMaps.App.ViewModel.CurrentPark.ParkNameUpper; 
     } 
     else PageTitle.Text = "Park Maps"; 
     // If the constructor has been called AND the PreservingPageState key is in the State dictionary, 
     // then the UI state for this page should be restored: 
     if (_newPageInstance && this.State.ContainsKey("PreservingPageState")) 
     { 
      // Restore the state of the UI: 
      try 
      { 
       _parkId = Utilities.TryGetValue<string>(State, "InfoParkId", "ti217"); 
       _parkPage = Utilities.TryGetValue<int>(State, "InfoDetailsParkPage", 0); 
       SubTitle.Text = Utilities.TryGetValue<string>(State, "InfoDetailsSubtitle", "Park Info"); 
       // NOTE: Browser not ready yet, so load web page in Default_Loaded above 
      } 
      catch { } // Don't restore anything if had trouble above 
     } 
    } 

そして、これは私が正しくあなたの質問を理解している場合、あなたが追加する必要がありますXAML

<StackPanel Orientation="Vertical" Grid.Row="0"> 
     <StackPanel x:Name="TitlePanel" Margin="8,4,8,4" Orientation="Horizontal"> 
      <Image Source="{Binding LogoImageSource}" ManipulationCompleted="LogoBar_ManipulationCompleted" Width="208" Stretch="Uniform" HorizontalAlignment="Left" Margin="9,0,0,0"/> 
      <TextBlock x:Name="PageTitle" Text="Park Maps" ManipulationCompleted="LogoBar_ManipulationCompleted" Width="250" Margin="-8,4,0,4" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="NoWrap" TextAlignment="Right" HorizontalAlignment="Stretch" /> 
     </StackPanel> 
     <TextBlock x:Name="SubTitle" Text="Legend" Margin="9,6,9,9" Style="{StaticResource PhoneTextLargeStyle}" TextWrapping="Wrap" TextAlignment="Center" /> 
    </StackPanel> 


    <!--ContentPanel - place additional content here--> 
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" MinHeight="697" VerticalAlignment="Stretch" > 



    </Grid> 
</Grid> 

答えて

1

です:

Stretch="Fill" 

をXAMLに追加します。

私があなたの質問を理解していない場合は、達成しようとしていることが明らかではないので、質問を言い換えてください。

ありがとうございました

+0

どこに追加しますか? – Kiwimoisi

+0

グリッドやWebrowserにSTRETCHというプロパティがないためです。 – Kiwimoisi

関連する問題