locked
How to change the white background of the List box if the items are less than the height of List Box?

    Question

  • Hi,

    I am Facing a problem of Changing the White Back ground of the List box .it happens when the list box items are less than the height of the list Box .Please let me know to resolve this issue

    PFA for better understanding.


    m venkatasuresh

    Monday, May 11, 2015 5:12 AM

All replies

  • It looks like the listbox isn't as big as it's container. What's the source code for this?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, May 11, 2015 1:28 PM
    Moderator
  • Hi Matt,

    This is the Source code that i have used in XAML Page:

     <Grid Background="BlueViolet">
            <ListBox Height="280" Width="550" Background="Red">
                <ListBoxItem>AAAA</ListBoxItem>
                <ListBoxItem>BBB</ListBoxItem>
                <ListBoxItem>CCCC</ListBoxItem>
                <ListBoxItem>DDDDD</ListBoxItem>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Padding" Value="30 0 30 0 " />
                        <Setter Property="Background" Value="Blue"/>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>

    After i run this Code the List box background instead of Red it is always showing White background .please provide a suggestion this 

    Thanks



    m venkatasuresh

    Tuesday, May 12, 2015 5:02 AM