我有三個頁面,並導航到每一頁,我將一個屬性綁定到框架的源屬性。如果我只是正常瀏覽頁面,但它在調用GoBack方法後突然停止工作,它工作得很好。如果我直接將URI設置爲Source屬性而不是使用綁定,但它工作正常,但實際上我正在使用MVVM實現,因此我不想直接設置Source屬性。綁定到幀的源屬性不起作用後Frame.GoBack
--xaml--
<navigation:Frame x:Name="_frame" Source="{Binding CurrentPage}"/>
--Code behind--
Uri _currentPage;
public Uri CurrentPage
{
get { return _currentPage; }
set
{
_currentPage = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("CurrentPage"));
}
}
// back
private void Button_Click(object sender, RoutedEventArgs e)
{
if (_frame.CanGoBack)
_frame.GoBack();
}
// test1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
CurrentPage = new Uri("/TestPage1.xaml", UriKind.Relative);
}
// test2
private void Button_Click_2(object sender, RoutedEventArgs e)
{
CurrentPage = new Uri("/TestPage2.xaml", UriKind.Relative);
}
// test3
private void Button_Click_3(object sender, RoutedEventArgs e)
{
CurrentPage = new Uri("/TestPage3.xaml", UriKind.Relative);
}
有誰知道如何解決這個問題呢?我嘗試了幾種方法,但沒有爲我工作。
由於提前,
柳