c# - 如何在后面的代码中获取 itemtemplate 的图像?
问题描述
<ListBox Grid.Row="1" Name="listBox" Background="#2e2e2e" BorderThickness="0" Margin="0,71.8,0,0">
<ListBox.ItemTemplate>
<DataTemplate >
<StackPanel Background="#1f1f1f" Height="150" Width="1169" MouseEnter="listBox_Selected" MouseLeave="listBox_Unselected" MouseLeftButtonDown="StackPanel_MouseLeftButtonDown">
<Image Name="listImg" Source="{Binding image}" Width="120" Height="150" HorizontalAlignment="Left" Stretch="Fill"/>
<TextBlock Foreground="White" Text="{Binding title}" FontSize="19" Margin="132,-140,0,0" HorizontalAlignment="Left"/>
<TextBlock Foreground="#FFABAAAA" Text="{Binding comment}" FontSize="17" Margin="132,-90,0,0" Height="Auto" TextWrapping="Wrap" HorizontalAlignment="Left"/>
<TextBlock Foreground="White" Text="{Binding username}" FontFamily="Poetsen One" FontSize="13" Margin="130,-25,0,0" Height="Auto" HorizontalAlignment="Left"/>
<TextBlock Foreground="CornflowerBlue" Text="{Binding cost}" FontSize="16" Margin="1080,-30,0,0" Height="Auto" HorizontalAlignment="Left"/>
<TextBlock Foreground="White" Text="{Binding id}" FontSize="15" Margin="0,0,0,0" HorizontalAlignment="Left"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我无法到达listImg
。
当我选择列表框项目时,我必须使用它。
我怎样才能在上面的代码中找到它?
解决方案
推荐阅读
- json - 如何通过 jsonḃ postgres 对列组求和
- java - 如何通过 IBM RSA 中的测试类检查主类的代码覆盖率?
- python - 如果所有元素都为 0,则删除子列表
- javascript - 如何 document.write() 一个 HTML DOM 元素对象?
- angular - 在选定的日期导航到不同的页面提交
- firebase - 异步 new Vue() 等待初始认证
- android - 通过位图解码提高 BaseAdapter 的性能
- python - 在 Python 中为对话机器人路由 Twilio SMS 响应
- android - 在不使用 Android 活动的情况下访问用户谷歌驱动器
- javascript - 如何获得删除按钮以从本地存储中删除单个项目