Enable button on another .xaml page

2019-09-04 18:41发布

I have a button 'ReadMore' defined Page.xaml. How may I enable it again when I click on a button that closes ThumbnailDetails.xaml? Users select an item @ a ListBox and they are directed to ThumbnailDetails.xaml by the way.

Somehow it's not working?

Page.xaml.cs:

void NewsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    StaffNews news = (StaffNews) NewsList.SelectedItem;
    if (news != null)
    {
        DetailsView.DataContext = news;
        DetailsView.Visibility = Visibility.Visible;
        //testing!!!
        ReadMore.IsEnabled = false;
    }                   
}

ThumbnailDetails.xaml.cs

//set the Visibility of the UserControl to "Collapsed" - 
//which will cause it to disappear from the screen and 
//return the user to the content below it:
void CloseBtn_Click(object sender, RoutedEventArgs e)
{
    Visibility = Visibility.Collapsed;

    //testing if button ReadMore will be reenabled on closebtn_clicked
    Page a = new Page();
    a.ReadMore.IsEnabled = true;
}

1条回答
相关推荐>>
2楼-- · 2019-09-04 19:04

What probably happens is that Page.xaml is reloaded thus state is lost. How do you 'direct' them to the other page? This is probably your problem as web applications are stateless.

查看更多
登录 后发表回答