Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 根据位置的不同,图像的渲染方式也不同_Wpf_Image_Rendering - Fatal编程技术网

Wpf 根据位置的不同,图像的渲染方式也不同

Wpf 根据位置的不同,图像的渲染方式也不同,wpf,image,rendering,Wpf,Image,Rendering,我有一个ItemsControl显示按钮列表。每个按钮都有一个图像作为其内容(png),但每行的图像看起来略有不同 下图是我看到的放大版: 以下是xaml: <ItemsControl ItemsSource="{Binding Items}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal

我有一个ItemsControl显示按钮列表。每个按钮都有一个图像作为其内容(png),但每行的图像看起来略有不同

下图是我看到的放大版:

以下是xaml:

<ItemsControl ItemsSource="{Binding Items}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel   Orientation="Horizontal">
                <TextBlock Name="tb1">hello</TextBlock>
                <Button Height="{Binding ElementName=tb1, Path=ActualHeight}" Padding="0,-3,-3,-3" BorderBrush="Transparent" Background="Transparent" >
                    <Image Stretch="Fill"  Source="stock_standard_filter.png" Margin="0">
                    </Image>
                </Button>
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

你好

我遇到了一个问题,并且能够使用
SnapsToDevicePixels=“True”
解决它,但这一次解决方案不起作用。我还尝试了
UseLayoutRounding=“True”
渲染。EdgeMode=“Aliased”

按钮的高度是绑定的,因此图像将被拉伸以填充按钮。由于WPF使用双精度(1/96英寸单位),因此必然会有一些舍入。在StackPanel上使用SnapsToDevicePixels和布局舍入可能会有所帮助,但只要拉伸图像,图像就会变得模糊


我的最佳猜测是设置“拉伸为无”,并尝试使用SnapsToDevicePixels和布局舍入。

按钮的高度是绑定的,因此图像将拉伸以填充按钮。由于WPF使用双精度(1/96英寸单位),因此必然会有一些舍入。在StackPanel上使用SnapsToDevicePixels和布局舍入可能会有所帮助,但只要拉伸图像,图像就会变得模糊


我的最佳猜测是设置“拉伸为无”,并尝试使用SnapsToDevicePixels和布局舍入。

如果尝试拉伸=“无”?@blindmeis:它的渲染方式仍然不同,但更糟糕的是图像太大。如果尝试拉伸=“无”?@blindmeis:它的渲染方式仍然不同,但更糟糕的是图像太大。