简体   繁体   中英

Transparent background to a listbox without border

I'm trying to apply transparent background to a listbox but I get a strange rendering.

The listbox itself is transparant but the border is so transparent that it overrides the background!

Here is the screenshot that demonstrate the problem: http://img10.imageshack.us/i/transparentborder.png/

I've tried the following without success:

On the ListBox

  • Background="{x:Null}"
  • BorderThickness="0"
  • BorderThickness="{x:Null}"

On the container and the scrollviewer the same properties but unsuccessful. I made other tests but always the same renderer ...

Thank you for any and all help!

EDIT : Sorry, it's not on the Windows Phone 7, it's on a desktop application

        <ListBox x:Name="ListBoxEntries" VerticalAlignment="Center"  HorizontalAlignment="Center" BorderThickness="{x:Null}"  Background="{x:Null}" SelectionChanged="ListBoxEntries_SelectionChanged" >
            <ListBox.ItemTemplate>
                itemtemplate code
            </ListBox.ItemTemplate>
        </ListBox>

Your ListBox looks a bit strange. Have you re-templated it with some XAML from desktop Silverlight? (the scroll bars don't look very phone/touch friendly)

My guess is that you have something in your customized ListBox template that is causing the unexpected rendering. Open it up in Blend and edit the template from there.

Thanks, Stefan Wick - Microsoft Silverlight

I resolved my problem. I used a template to make "zune like" application. And with the template i have the following code behind :

protected override void OnInitialized(EventArgs e)
            {
                AllowsTransparency = false;
                ResizeMode = ResizeMode.NoResize;
                Height = 480;
                Width = 852;
                WindowStartupLocation = WindowStartupLocation.CenterScreen;
                WindowStyle = WindowStyle.None;

                SourceInitialized += HandleSourceInitialized;

                GotKeyboardFocus += HandleGotKeyboardFocus;
                LostKeyboardFocus += HandleLostKeyboardFocus;

                base.OnInitialized(e);
            }

I just change the propertie of AllowsTransparency to true and it resolve the problem.

Thanks for your answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM