2012-05-15 4 views
0

저는 Windows 전화 코드 작성에 새로운 것이므로 초보자 문제라고 생각합니다. :) 내 웹 브라우저는 보이지 않습니다. 나는 그것이 내 클래스의 생성자를 탐색한다고 말했기 때문에 그것이 처음이라고 생각했지만, 그것을 변경해도 아무 것도 해결하지 못했습니다.내 전화 페이지에 표시 할 웹 브라우저를 가져올 수 없습니다.

아무도 나에게 설명 할 수 있습니까? 여기

public partial class MainPage : PhoneApplicationPage 
    { 
     string site = "http://google.com/"; 

     // Constructor 
     public MainPage() 
     { 
      InitializeComponent(); 

      this.Loaded += new RoutedEventHandler(MainPage_Loaded); 

     } 


     private void MainPage_Loaded(object sender, RoutedEventArgs e) 
     { 
      wB.Navigate(new Uri(site, UriKind.Absolute)); 
      wB.Navigating += new EventHandler<NavigatingEventArgs>(wB_Navigating); 
     } 

     void wB_Navigating(object sender, NavigatingEventArgs e) 
     { 
      System.Diagnostics.Debug.WriteLine(e.Uri); 
      if (e.Uri.ToString() != (site)) 
      { 
       System.Diagnostics.Debug.WriteLine("lalala"); 
       // NavigationService.Navigate(new Uri("/Panorama.xaml", UriKind.Relative)); 
      } 
     } 
    } 
} 

내 XAML입니다 : 여기

뒤에 내 코드입니다

당신이, WebBrowser 컨트롤에 대한 VerticalAlignment = "최고"로 설정이 속성을 제거하기 때문에 것 같다
<phone:PhoneApplicationPage 
    x:Class="LaBanquePostale.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    shell:SystemTray.IsVisible="True"> 

    <!--LayoutRoot is the root grid where all page content is placed--> 
    <Grid x:Name="LayoutRoot" Background="Transparent"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto"/> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 

     <!--TitlePanel contains the name of the application and page title--> 
     <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> 
      <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/> 
      <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
     </StackPanel> 

     <!--ContentPanel - place additional content here--> 
     <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
      <phone:WebBrowser Name="wB" VerticalAlignment="Top" d:LayoutOverrides="Width"/> 
      <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/></Grid> 
    </Grid> 

</phone:PhoneApplicationPage> 

답변

2

웹 브라우저와 TextBlock이 동일한 그리드 행에 있습니다. TextBlock이 WebBrowser를 숨기고 WebBrowser의 높이가 0 일 수 있습니다. 이는 verticalAlignment가 Top으로 설정되어 있기 때문입니다.

TextBlock을 제거하고 VerticalAlignment를 Stretch로 설정하고 작동하는지 확인하십시오.

궁극적으로 당신의 그리드는 두 개의 RowDefinitions를 가지고 있고, 같은 것을 보일 것입니다 : 당신이 가장 최고입니다

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="*" /> 
      <RowDefinition Height="Auto" /> 
     </Grid.RowDefinitions> 
     <phone:WebBrowser Name="wB" VerticalAlignment="Stretch" Grid.Row="0" d:LayoutOverrides="Width"/> 
     <TextBlock HorizontalAlignment="Left" Grid.Row="1" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/></Grid> 
    </Grid> 
+0

에서 제공하는 추론을 확인하십시오. WP7에서 UI 항목이 작동하는 방식을 여전히 유감스럽게 생각하지 않습니다. 그러나 나는 더 가까이 볼 것이다! Thx guys –

+0

많은 사람들이 당신이 기대하는대로 행동하지 않는다는 것을 알게 될 것입니다. – Robaticus

0

설정, 샘플 프로젝트에서 WebBrowser 컨트롤을 제공합니다.

+0

친구를, 즉 당신이 나에게 오늘을 도와 두 번째 시간이다, 왜 그렇게합니까? –

+0

문제는 없습니다. Robaticus –

관련 문제