【问题标题】:Silverlight ListBox ItemTemplate: Make certain elements visible when item is selectedSilverlight ListBox ItemTemplate:选择项目时使某些元素可见
【发布时间】:2010-10-23 16:45:44
【问题描述】:

在 Windows Phone 7 Silverlight 应用程序中,我有这个 ListBox:

<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 中)?

【问题讨论】:

  • 您可以在 ListBoxItem 上添加一个简单的故事板,用于切换 TextBlock 的可见性

标签: silverlight xaml windows-phone-7


【解决方案1】:

您可以使用 VisualStateManager 根据 SelectionState 更改可见内容。

可以在http://forums.silverlight.net/forums/p/180002/405838.aspx找到基于选择(但不是在电话上)进行类似操作的示例

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多