2010-10-23 20 views
4

在Windows Phone 7的Silverlight應用程序使某些元素可見的,我有這樣的列表框:Silverlight的ListBox的ItemTemplate中:當項目被選中

<ListBox ItemsSource="{Binding Path=Programs}" >       
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <StackPanel> 
       <StackPanel Orientation="Horizontal"> 
        <TextBlock Text="{Binding Begin, Converter={StaticResource TimeOfDayConverter}}" Margin="0,0,10,0" Width="46" /> 
        <TextBlock Text="{Binding Title}" FontSize="30" /> 
       </StackPanel> 
       <TextBlock x:Name="txtDescription" Text="{Binding Description}" Margin="56,0" Visibility="Collapsed" /> 
      </StackPanel> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 

我需要有一個名爲txtDescription被默認倒塌TextBlock的,但設置它在項目被選中時顯示。我該怎麼做(最好在XAML中)?

+0

找到您可以用來切換的TextBlock – indyfromoz 2010-10-23 19:53:48

回答

3

您可以使用VisualStateManager根據SelectionState更改可見內容。

基於選擇做類似的操作(但電話不是)的例子可以在http://forums.silverlight.net/forums/p/180002/405838.aspx

+0

的能見度能否請你幫我ListBoxItem中添加一個簡單的故事板在這個http://stackoverflow.com/questions/22578128/list-box-with-multiple-data-template-style-for-selected-item – user2056563 2014-03-24 11:39:01

相關問題