[英]Find the text property of a textblock within a listitem
I have a Listbox within my WP7 application, and inside the DataTemplate I have a toolkit:WrapPanel which then has a context menu (toolkit). 我在WP7应用程序中有一个列表框,在DataTemplate中有一个工具箱:WrapPanel,然后有一个上下文菜单(工具箱)。 How can I get the text of a textblock inside the listbox datatemplate when they click on the contextmenu menuitem?
当他们单击上下文菜单菜单项时,如何在列表框数据模板中获取文本块的文本?
Hope this makes sense heres some code: 希望这里的一些代码有意义:
<ListBox x:Name="FirstListBox" Margin="0,0,-12,0">
<ListBox.ItemTemplate>
<DataTemplate>
<toolkit:WrapPanel Margin="0,0,0,17" Width="432" Height="auto">
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="copy" Click="copytoCB_Click"></toolkit:MenuItem>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<TextBlock Text="{Binding author}" TextAlignment="Left" TextWrapping="NoWrap" Style="{StaticResource PhoneTextExtraLargeStyle}" MinWidth="430" />
<TextBlock Text="{Binding content}" TextWrapping="Wrap" Name="txtContent" Style="{StaticResource PhoneTextSubtleStyle}"/>
</toolkit:WrapPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Thanks, 谢谢,
Michael 麦可
Here you can see WPF Commands in action, maybe a good place to start. 在这里,您可以看到运行中的WPF命令 ,也许是一个不错的起点。 :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.