【发布时间】:2012-02-15 06:18:39
【问题描述】:
我需要在列表框项目模板中设置选择更改事件。我的列表框由三个文本块和一个图像组成。我只想获取第三个文本块文本,当我选择第三个文本块时,文本块中的文本将显示为弹出窗口。
我使用可视化树搜索文本块,但它采用第一个文本块的值而不是第三个文本块的值。我该怎么做才能获得第二个和第三个文本块的值。只有当我单击列表框中的文本块而不是整个列表框项时,我才需要触发弹出窗口。
<ListBox Name="listBox1" Width="Auto" SelectionChanged="Listbox1_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Height="165" HorizontalAlignment="Left" Margin="10,40,-400,0" VerticalAlignment="Top" Width="175" Source="{Binding thumb}"/>
<TextBlock Name="pagetext" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="195,-135,-200,0" Text="{Binding page}" Foreground="#FF170101" />
<TextBlock Name="titletext" Width="1000" TextWrapping="NoWrap" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="195,-167,-200,0" Text="{Binding title}" Foreground="#FF170101" />
<TextBlock Name="text" Width="1000" TextWrapping="NoWrap" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="195,-167,-200,0" Text="{Binding title}" Foreground="#FF170101" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
【问题讨论】:
标签: c# wpf silverlight windows-phone-7 xaml