开发者

wpf transparency

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 ht开发者_运维问答tp://www.freeimagehosting.net/uploads/659cd194e7.png


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


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜