另一个.xaml页面上的启用按钮 [英] Enable button on another .xaml page

查看:128
本文介绍了另一个.xaml页面上的启用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个定义为 Page.xaml 的按钮'ReadMore'.当我单击关闭ThumbnailDetails.xaml的按钮时,如何再次启用它?用户选择一个ListBox项,然后将其定向到ThumbnailDetails.xaml.

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.

以某种方式不起作用?

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;
}

推荐答案

可能发生的情况是重新加载了Page.xaml,从而导致状态丢失.您如何将它们定向"到另一页?这可能是您的问题,因为Web应用程序是无状态的.

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.

这篇关于另一个.xaml页面上的启用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆