Search code examples
wpfitemscontrolseparator

Separator in ItemsControl renders in different shades for each item


I have an ItemsControl presenting TextBlocks, with a Separator at the bottom of each item.

My problem is that each Separator is rendered in a slightly different shade of gray - it looks really dodgy:

enter image description here

Here is my XAML:

<ItemsControl ItemsSource="{Binding Path=Items}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel></StackPanel>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding}" ></TextBlock>
                <Separator></Separator>
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

I have also tried using a thin border instead of the Separator, with the same result.

How can I make each line identical?


Solution

  • Try SnapsToDevicePixels="True"

    <ItemsControl ItemsSource="{Binding Path=Items}" SnapsToDevicePixels="True">
    

    If this doesn't help you can also try with