0

I am using a ListBox with a DataTemplate to create the below map legend. I would like to get the ListBox to have a transparent background (where it is now white) and the ListItems to retain their existing white background. The two legends would then appear to float with a transparent gap between.

I have tried setting the ListBox background with a SolidBrush set to 0 opacity but that doesn't seem to work. I understand that items in the tree cannot have transparency that is less than items above in the tree. Is that my issue and how do I resolve?

Thanks

alt text http://www.freeimagehosting.net/uploads/659cd194e7.png

1
  • Oh - and the items in the ListBox can have a transparent background as well.
    – RQDQ
    Aug 11, 2010 at 18:38

2 Answers 2

2

You can set the Background to {x:Null}.

1

Did you try setting the background color of the ListBox to "Transparent" (literally)?

Here is some code that worked for me:

<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" Background="Blue">
    <Grid>

        <ListBox x:Name="ListBox1" Margin="12,25,114,97" Background="#00E51A1A">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="4" Height="20" Width="100" Background="Yellow" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

    </Grid>
</Window>
1
  • Can you share some more of your XAML? I'm able to construct a ListBox that has transparency around each of its templated items...
    – RQDQ
    Aug 11, 2010 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.