开发者

Enable button on another .xaml page

I have a button 'ReadMore' defined Page.xaml. How may I enable it a开发者_C百科gain 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;
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜