【发布时间】:2019-10-31 22:50:57
【问题描述】:
我创建了 WPF 应用程序,其中包含用于 windows7 的复选框(checklistbox)的列表框。我在 Windows 10 上安装了相同的应用程序,GUI 看起来非常不同。在 Windows 7 上,同一行中的复选框。但在 windows 10 上,box 较高,文字较低(请参见图片)
<ListBox x:Name="lbSchlagwoerter" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinWidth="300" MaxHeight="390" Grid.Row="1" Grid.RowSpan="3" Grid.Column="3" Margin="5,5,5,5">
<ListBox.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<CheckBox Margin="5,2" IsChecked="{TemplateBinding IsSelected}">
<ContentPresenter />
</CheckBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Resources>
</ListBox>[enter image description here][1]
【问题讨论】:
-
<CheckBox VerticalContentAlignment="Center"试试这个或者你可以设置 ContentPresenter VerticaltAlignment="Center" -
它适用于 VerticalContentAlignment,非常感谢 Avinash :)
标签: c# wpf windows-7 listbox windows-10