相关疑难解决方法(0)

我的图像很模糊!为什么WPF的SnapsToDevicePixels不工作?

我在WPF applcation中使用了一些图像.

XAML:

<Image Name="ImageOrderedList"
       Source="images/OrderedList.png"
       ToolTip="Ordered List"
       Margin="0,0,5,5"
       Width="20"
       Height="20"
       SnapsToDevicePixels="True"
       MouseUp="Image_MouseUp"
       MouseEnter="Image_MouseEnter"
       MouseLeave="Image_MouseLeave" />
Run Code Online (Sandbox Code Playgroud)

但是,它们显得模糊:

死链接 - 模糊的WPF图像

这是一个放大的,并排的比较.原件在左侧:

死链接 - 模糊的WPF图像缩放

为什么这SnapsToDevicePixels="True"条线不能阻止这个问题呢?

.net wpf xaml image

164
推荐指数
7
解决办法
5万
查看次数

选定的TabItem中的图像不清晰

我有一个TabControl.每个TabItem的标题包含一个带有图标和Label的StackPanel.

<TabControl>
  <TabItem>
    <TabItem.Header>
      <StackPanel Orientation="Horizontal">
        <Image Source="/LoginPanel;component/Icons/icoLogin.ico"</Image>
        <Label VerticalContentAlignment="Center">Login</Label>
        </StackPanel>
      </TabItem.Header>
    </TabItem.Header>
    <!--some further code here-->
  <TabItem>
  <!--some further code here-->
<TabControl>
Run Code Online (Sandbox Code Playgroud)

每个未选择的TabItem中的每个图标都按预期显示.当前所选TabItem中的图标有些混浊.如果我切换到另一个标签,取消选择的标签图标变得清晰; 新选择的图标变为阴天.

我已经尝试过以下方法来解决这个问题:

SnapsToDevicePixels="True"
Run Code Online (Sandbox Code Playgroud)

但没有任何反应

要么

Width="32" Height="32"
Run Code Online (Sandbox Code Playgroud)

要么

Stretch="None"
Run Code Online (Sandbox Code Playgroud)

防止缩放.所有这些都没有任何影响.有人可以给我一个提示吗?提前致谢

wpf icons tabcontrol ico tabitem

11
推荐指数
2
解决办法
1254
查看次数

旋转标签后,TabControl项目标题文本显示模糊

我需要创建一个WPF TabControl控件,其中选项卡向左旋转.

我在网上找到的资源表明,这可以通过将以下两件事应用于TabControl来完成:

<Setter Property="LayoutTransform">
   <Setter.Value>
     <RotateTransform Angle="270"/>
   </Setter.Value>
</Setter>
Run Code Online (Sandbox Code Playgroud)

<TabControl TabStripPlacement="Left" ...
Run Code Online (Sandbox Code Playgroud)


所有这些工作,并根据需要显示选项卡,但由于某些原因,选项卡中的标题文本在轮换后显得模糊,请说明为什么会发生这种情况,如果我有什么办法可以解决这个问题.

完成XAML:

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TabControl BorderBrush="Gray" BorderThickness="1" TabStripPlacement="Left">
            <TabControl.ItemContainerStyle>
                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="LayoutTransform">
                        <Setter.Value>
                            <RotateTransform Angle="270"/>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Template">
                        <Setter.Value>                            
                            <ControlTemplate TargetType="{x:Type TabItem}">
                                <Grid>
                                    <Border Name="Border" BorderBrush="Gray" BorderThickness="1" CornerRadius="6,6,0,0">
                                        <ContentPresenter x:Name="ContentSite"
                                        VerticalAlignment="Center" HorizontalAlignment="Center" 
                                        ContentSource="Header" Margin="12,2,12,2"/>
                                    </Border>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.ItemContainerStyle>
            <TabItem Header="Item 1" />
            <TabItem Header="Item 2" />
            <TabItem Header="Item 3" />
        </TabControl>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

c# wpf xaml .net-4.0

1
推荐指数
1
解决办法
2666
查看次数

标签 统计

wpf ×3

xaml ×2

.net ×1

.net-4.0 ×1

c# ×1

ico ×1

icons ×1

image ×1

tabcontrol ×1

tabitem ×1