开发者

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 Separat开发者_如何学Goor is rendered in a slightly different shade of gray - it looks really dodgy:

Separator in ItemsControl renders in different shades for each item

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?


Try SnapsToDevicePixels="True"

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

If this doesn't help you can also try with

  • UseLayoutRounding="True" (WPF 4)
  • RenderOptions.EdgeMode="Aliased" (Turn of anti-aliasing)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜