Problems populating with ListBox WPF

In my application, I defined the DataTemplate for ListBoxas a grid with a stretched border and with a label inside it. For some reason, I have the following result:

alt text http://dl.getdropbox.com/u/829214/q1.gif

As you can see, ListBoxthere are indents between the border and the border of the element, and these β€œindents” are marked when the element is selected. What property should be changed to resolve it?

Edited by:

Kent's answer made me realize that the border in my DataTemplate is placed inside the element container (list item) and does not replace it as I thought. In the end, I set the item container style add-on to 0, and my problem was resolved.

+3
source share
1 answer

I do not see the image due to a problem with the proxy server, but I think you just need to set the container background:

<ListBox>
    <ListBox.ItemContainerStyle>
        <Setter Property="Background" Value="White"/>
    </ListBox.ItemContainerStyle>
</ListBox>

If you want the highlight highlight to appear outside the filled area, just set it Backgroundback to nullin the child container.

+2
source

Source: https://habr.com/ru/post/1707250/


All Articles