I'm trying to create a transparent ListBox in a WPF application. I want the ListBox to be completely transparent, thus a background image is visible "behind" the ListBox. However, I want my ListBox items to be totaly opaque, that is to say, they lay on top of the background image.
Do anyone know how I can accomplish this?
Thanx in advance!
Sure, it's as simple as setting the Background and BorderBrush properties on the ListBox to Transparent and then setting a Background for the ListBoxItems:
<StackPanel Background="Red">
<ListBox Background="Transparent" BorderBrush="Transparent">
<ListBox.Resources>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Background" Value="White" />
<Setter Property="Margin" Value="1" />
</Style>
</ListBox.Resources>
<ListBoxItem Content="First Item"/>
<ListBoxItem Content="Secton Item"/>
</ListBox>
</StackPanel>
NOTE: I added a Margin to the ListBoxItems just to demostrate the spacing between the ListBoxItems will show all the way through to the surrounding StackPanel's red background.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With