2011-10-03 25 views
2

我遇到了一個WPF相當奇怪的問題。當我在窗體上放置按鈕時,它們在設計時看起來很好,但在Windows XP上看起來很好,但是當應用程序在Windows 7上運行時,邊緣會變得破損。WPF斷邊

這是正常的圖標的屏幕截圖(XP和設計時間) Normal Edges

這裏是一個用破碎的邊緣(Windows 7)中 Broken Edges

任何想法?

編輯:

如這裏要求是我使用的按鈕

<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> 
+4

你能發佈你的Button的XAML代碼嗎? – Rachel

+0

@Rachel代碼示例添加到原來的帖子,思考它我應該張貼在第一位 –

+0

也許與此有關? http://blogs.msdn.com/b/text/archive/2009/08/27/layout-rounding.aspx –

回答

1

也許代碼與此有關?從博客文章 Layout Rounding on the WPF Text Blog

摘要:

WPF的佈局引擎經常給人元素的子像素位置。抗鋸齒算法使得這些子像素定位元素在過濾之後被渲染到多個物理像素上。這可能會導致模糊的線條和其他不理想的渲染僞影。在WPF 4.0中引入了佈局舍入,允許開發人員強制WPF佈局系統在像素邊界上定位元素,消除了亞像素定位的許多負面影響。

附加屬性UseLayoutRounding已被引入到允許對切換或關閉佈局舍入功能。 該屬性可以是True或False。該屬性的值由元素的子元素繼承。

<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> 
+1

你可以在這裏總結這個博客 - 它有助於防止URL發生變化。 – ChrisF