Silverlight 如何在自定义列表框中获取组件的内容
如何获取在自定义列表中单击的超链接按钮的内容。XAML的代码发布在下面Silverlight 如何在自定义列表框中获取组件的内容,silverlight,windows-phone-7,Silverlight,Windows Phone 7,如何获取在自定义列表中单击的超链接按钮的内容。XAML的代码发布在下面 <ListBox Height="513" HorizontalAlignment="Left" Margin="9,88,0,0" Name="listBox1" VerticalAlignment="Top" Width="436"> <ListBox.ItemTemplate> <DataTemplate>
<ListBox Height="513" HorizontalAlignment="Left" Margin="9,88,0,0" Name="listBox1" VerticalAlignment="Top" Width="436">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="132">
<TextBlock Text="{Binding ImageSource}" Height="73" Width="73" VerticalAlignment="Top" Margin="0,10,8,0"/>
<StackPanel Width="370">
<HyperlinkButton Content="{Binding usrname}" Click="eventhandler" Foreground="#FFC8AB14" FontSize="24" />
<TextBlock Text="{Binding msg}" TextWrapping="Wrap" FontSize="20" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
请提前多谢您的事件处理程序将有一个源参数,它是对
HyperlinkButton
的引用。您可以按如下方式使用它:
public void eventhandler(object source, EventArgs e)
{
HyperlinkButton button = source as HyperlinkButton;
var foo = button.Content;
}
什么是“发送者”,你是说来源吗??