浏览器控件未显示整个页面
本文关键字:显示 控件 浏览器 | 更新日期: 2023-09-27 18:26:11
我想知道为什么我第一次尝试用WebBrowser加载信息时,页面被裁剪了,而第二次却很好地显示了信息。
或者,例如,方向为纵向,当我转到横向并返回人像时,将显示所有内容
这是我使用的代码。
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>
如果我正确理解了你的问题,你需要添加:
Stretch="Fill"
到您的XAML。
如果我不理解你的问题,请重新表述这个问题,因为你想达到的目标并不明显。
感谢