我如何在后面的代码中到达itemtemplate的图像?

时间:2018-08-31 15:27:24

标签: c# wpf 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

选择列表框项目时必须使用它。

如何在上面的代码中找到它?

0 个答案:

没有答案