Reputation: 1623
I have a code like that:
<ListBox Height="522" HorizontalAlignment="Left" Margin="20,162,0,0" Name="listBox1" VerticalAlignment="Top" Width="448" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="132">
<Image Source="{Binding IconSource}" Height="48" Width="48" VerticalAlignment="Top" Margin="0,10,8,0"/>
<StackPanel Width="370">
<TextBlock Text="{Binding Text}" FontSize="36" VerticalAlignment="Top" Margin="0,20,20,0" Width="380" Height="Auto"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
In Listbox i have 2 for-loop elements - image (icon) and text. I need to fill the background of a particular image, but I do not know how to do it. In other words:
sorry for little stupid question and thanks for answers.
Upvotes: 1
Views: 727
Reputation: 1425
If I understand your problem correctly, you just need to add a background to the StackPanel
. Change the color and opacity properties until you get the effect that you want.
<ListBox Height="522" HorizontalAlignment="Left" Margin="20,162,0,0" Name="listBox1" VerticalAlignment="Top" Width="448" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="132" Padding>
<StackPanel.Background>
<SolidColorBrush Color="Black" Opacity="0.4" />
</StackPanel.Background>
<Image Source="{Binding IconSource}" Height="48" Width="48" VerticalAlignment="Top" Margin="0,10,8,0"/>
<StackPanel Width="370">
<TextBlock Text="{Binding Text}" FontSize="36" VerticalAlignment="Top" Margin="0,20,20,0" Width="380" Height="Auto"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Upvotes: 4