启用&禁用标签项

时间:2011-08-05 19:13:24

标签: c# xaml silverlight-2.0

我在标签控件@ Page.xaml中有2个标签项(StaffNews& TopPicks)。当我选择一个ListBox项目时,如何通过将其ThumbnailDetails的可见性设置为true来执行人工弹出窗口,我怎么能禁用另一个?

@ Page.xaml:

xmlns:Digg="clr-namespace:News"
...
<tab control>
<TabItem x:Name="TabItemStaffNews" >    
...
<ListBox x:Name="NewsList" SelectionChanged="NewsList_SelectionChanged">
...
</ListBox>
<TabItem x:Name="TabItemTopPicks" >    
...
<!-- cause ThumbnailDetails user control to appear on the screen -->
<Digg:ThumbnailDetails x:Name="DetailsView" Visibility="Collapsed" />
</tab control>

@ 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;
            //i've tried this.TabItemTopPicks.IsEnabled = false;
            //works, but after i close the artificial pop-up 'DetailsView', TabItemsTopPicks' tab item state is still disabled
            //tried to access TabItemTopPicks & enable it from 'ThumbailDetails.xaml.cs, doesn't work           
        }
     }

@ ThumbnailDetails.xaml.cs:

//将UserControl的可见性设置为“Collapsed” - 这将导致它从屏幕上消失并将用户返回到其下面的内容:

    void CloseBtn_Click(object sender, RoutedEventArgs e)
    {
        Visibility = Visibility.Collapsed;
    }

0 个答案:

没有答案