2015-01-20 2 views
1

기본 질문 일 수 있지만 이미로드 된 후 컨텐츠를 업데이트하도록 페이지를 강제 설정하는 방법은 무엇입니까? 웹 요청 후 페이지를 동적으로 업데이트하려고합니다. 이벤트가 시작되지만 내용을 새로 고치는 것 같지 않습니다. 메모리에서 그 일을 오류 코드에 대한이벤트의 Xamarin ContentPage 컨텐츠가 작동하지 않습니다.

public StartPage : ContentPage 
{ 
    public StartPage() 
    { 
     var layout = new StackLayout 
     { 
      Children = 
      { 
       new Label { Text = "Preview Page" } 
      } 
     }; 

     this.Content = layout; 
    } 

    //this gets called from a web service call with the text to display 
    public void Update(string text) 
    { 
     var layout = new StackLayout 
     { 
      Children = 
      { 
       new Label { Text = text } 
      } 
     }; 

     this.Content = layout; 

     //this fires, but nothing changes 
     //how can I force the page to refresh?? 
    } 
} 

Aplogies이있는 경우

답변

6

당신은 같은 Device.BeginInvokeOnMainThread() 안에 넣어한다 (내 앞에 정확한 코드가없는) 아래

public void Update(string text) 
{ 
    Device.BeginInvokeOnMainThread(() => 
    { 
    var layout = new StackLayout 
    { 
     Children = 
     { 
      new Label { Text = text } 
     } 
    }; 

    this.Content = layout; 
    }); 
} 
+0

Ooof, 나는 집에 도착했을 때 시험 할 것이다. 그런 어리석은 감시를 믿을 수 없다! – chad

관련 문제