Enable button on another .xaml page

纵饮孤独 提交于 2019-12-13 03:55:32

问题


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:


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.



来源:https://stackoverflow.com/questions/6799117/enable-button-on-another-xaml-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!