我有一个按钮'ReadMore'
定义Page.xaml。当我点击关闭ThumbnailDetails.xaml
的按钮时,我如何再次启用它?用户选择一个项目@ a ListBox
,然后他们被引导到ThumbnailDetails.xaml
。
为什么它不工作?
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;
}
可能发生的是Page。Xaml被重新加载,因此状态丢失。如何将他们"引导"到另一个页面?这可能是你的问题,因为web应用程序是无状态的。