为什么我的 WPF 应用程序中复选框的宽度在 XP 和 Win7 之间不同? [英] How come the width of a checkbox in my WPF-application differ between XP and Win7?

查看:20
本文介绍了为什么我的 WPF 应用程序中复选框的宽度在 XP 和 Win7 之间不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 WPF 应用程序.我有一个包含复选框的列标题的数据网格.我将此复选框用于选中/取消选中所有功能.当我在 Win7 中运行该应用程序时,它看起来很正常,但在 XP 上,复选框被奇怪地压缩,并且在单击时不检查.任何反馈将不胜感激.

I am making a WPF-application.I have a datagrid with a column header that contains a checkbox. I use this checkbox for check/uncheck-all functionality. When I run the application in Win7 it looks normal but on XP the the checkbox is weirdly compressed and does not check when clicked on. Any feedback would be greatly appriciated.

受影响的代码:

<Grid>
    <DataGrid RowDetailsVisibilityMode="VisibleWhenSelected" SelectionMode="Extended" SelectionUnit="Cell" AutoGenerateColumns="False" IsReadOnly="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" Height="Auto" Margin="10,10,10,10" Name="dgSurveyGroups" VerticalAlignment="Top" RowHeight="26" AlternatingRowBackground="Gainsboro" RowHeaderWidth="0" HorizontalAlignment="Left" Width="346">
        <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding description, Mode=OneWay}" Header="Surveygroup" Width="*"/>
            <DataGridCheckBoxColumn Binding="{Binding Active}" Header="" Width="24">
                <DataGridCheckBoxColumn.HeaderTemplate>
                    <DataTemplate>
                        <CheckBox Name="SuperCheckBox"/>
                    </DataTemplate>
                </DataGridCheckBoxColumn.HeaderTemplate>
            </DataGridCheckBoxColumn>
            <DataGridTemplateColumn Header="Start Date" Width="110">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding startDate, StringFormat=d}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
                <DataGridTemplateColumn.CellEditingTemplate>
                    <DataTemplate>
                        <DatePicker SelectedDate="{Binding startDate}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellEditingTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn Header="End Date" Width="110">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding endDate, StringFormat=d}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
                <DataGridTemplateColumn.CellEditingTemplate>
                    <DataTemplate>
                        <DatePicker SelectedDate="{Binding endDate}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellEditingTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>
</Grid>

Win7:

WinXP:

WinXP:

推荐答案

您可以强制 WPF 在 XP 中使用 Windows Vista/7 Aero 主题.这是 WPF 使用其矢量图形自行重新实现所有系统图形功能这一事实的有趣含义之一.

You can force WPF to use the Windows Vista/7 Aero theme in XP. It's one of the fun implications of the fact that WPF reimplements all the system graphical features on its own using its vector graphics.

怎么做.

但是请注意,该应用程序在 Windows XP 中看起来有点不合适(带有所有现代玻璃按钮等).

However be warned, the application will look a bit out of place in Windows XP (with all the modern glassy buttons and so on).

这篇关于为什么我的 WPF 应用程序中复选框的宽度在 XP 和 Win7 之间不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆