我試圖在ToggleButton
的文本之前放置圖像。一切進行得都很順利。但圖像顯示不正確。我在這裏放大了圖像,以便您可以看到我在說什麼。如您所見,圖像的某些部分顯示不正確。ToggleButton中的圖像在WPF中無法正確顯示
的形象,我想顯示
結果
縮放結果
<BitmapImage x:Key="ColumnsLayoutMiniIcon" UriSource="pack://application:,,,/Main/Resources/dark/images/mini/columns_layout_mini_icon.png"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<StackPanel Orientation="Horizontal">
<Image x:Name="Border" Width="13" Height="13" Source="{StaticResource ColumnsLayoutMiniIcon}">
</Image>
<Border x:Name="Content"
Padding="10 0 10 0">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="-2 -3 0 0"
RecognizesAccessKey="True" />
</Border>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Cursor" Value="Hand"/>
</Trigger>
<Trigger Property="IsChecked" Value="False">
</Trigger>
<Trigger Property="IsChecked" Value="True">
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Foreground" Value="LightGray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<RadioButton Content="Plan View"
GroupName="View"
Style="{StaticResource BaseToggleButton}"
Checked="SwitchToPlanView_Selected"
IsEnabled="{Binding SwitchToModelViewsEnabled}"
IsChecked="{Binding SwitchToPlanViewSelected}">
</RadioButton>
這就像一個像素跳過O_o。希望你找到答案,很奇怪! – DLeh
@DLeh現在幾個小時我都在竊聽我:( – Vahid