2017-12-05 8 views
0

UWP 응용 프로그램에서 C# 코드로 웹보기를 만들고 있습니다. LoadCompleted 이벤트를 첨부했습니다. 이 이벤트가 ActaulHeight 및 ActualWidth 트리거를 가져올 때 0입니다. MinWidth 및 MinHeight를 500으로 설정하려고 시도했지만 작동하지 않습니다. ActualHeight 및 ActualWidth in Webview

나는 XAML에서 웹보기 컨트롤을 만들어하지만 경우의 ActualHeight에 같은 일을했고, ActualWidth 여기

500 코드입니다 :

public WebView _webView { get; set; } 

public ViewPage() 
{ 
    this.InitializeComponent(); 
    _webView = new WebView 
     { 
      HorizontalAlignment = HorizontalAlignment.Stretch, 
      VerticalAlignment = VerticalAlignment.Top, 
      Source = new Uri(@"https://www.google.com"), 
      MinHeight = 500, 
      MinWidth = 500 
     }; 
} 

    private void _webView_LoadCompleted(object sender, NavigationEventArgs e) 
    { 
     // Here, when I debug _webview ActualHeight and ActaulWidth is zero. 
    } 

답변

0

ActualWidthActualHeight이의 크기를 반영 레이아웃의 UI 요소. C# 코드에서는 WebView 클래스의 인스턴스 만 만들었지 만 실제로 페이지의 아무 곳에 나 배치하지 않았으므로이 값은 0입니다. 당신이 XAML을 사용하는 경우 반대로

은뿐만 아니라 당신은 WebView 클래스의 인스턴스를 생성, 또한 그렇게 ActualWidth, 응용 프로그램을 실행하고 ActualHeight는 실제 치수를 포함 할 때 표시 한 페이지에이 UI 요소를 포함 해당 페이지의 UI 요소