WPF Broken edges
I’m experiencing a rather strange problem with WPF. When I place buttons on a form they look fine in design time, they look fine on windows XP but when the application is run on windows 7 the edges become broken.
Here is a screen shot of the normal icons (XP and design time)
And here is one with the broken edges (windows 7)
开发者_C百科Any ideas?
EDIT:
As requested here is the code I use for the button
<Button Height="38" HorizontalAlignment="Center" Name="cmdChange_dataset" VerticalAlignment="Center" Width="130" Grid.Column="0" >
<Grid Width="120">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="/Sales_express_lite_WPF;component/Images/note_to_self_32.png" Stretch="None" Grid.Column="0" HorizontalAlignment="Left"/>
<Label Content="Change DataSet" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<Button.Effect>
<DropShadowEffect BlurRadius="5" Color="Gray" />
</Button.Effect>
</Button>
Maybe is related to this? Layout Rounding on the WPF Text Blog
Summary from the blog post:
WPF’s layout engine frequently gives elements sub-pixel positions. Antialiasing algorithms cause these sub-pixel positioned elements to be rendered over multiple physical pixels after filtering. This can result in blurry lines and other non desirable rendering artifacts. Layout rounding has been introduced in WPF 4.0 to allow developers to force the WPF layout system to position elements on pixel boundaries, eliminating many of the negative side effects of sub-pixel positioning.
The attached property UseLayoutRounding
has been introduced to allow layout rounding functionality to be toggled on or off.
This property can either be True or False. The value of this property is inherited by an element’s children.
<Grid UseLayoutRounding="True" Height="100" Width="200">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Rectangle Grid.Row="0" Fill="DarkBlue"/>
<Rectangle Grid.Row="1" Fill="DarkBlue"/>
<Rectangle Grid.Row="2" Fill="DarkBlue"/>
</Grid>
精彩评论