简体   繁体   English

XP和Windows 7之间的C#区别

[英]C# difference between XP and Windows 7

When I am running this code in Windows XP I get a rectangle around the radiobutton. 当我在Windows XP中运行此代码时,单选按钮周围会出现一个矩形。 In windows 7 not. 在Windows 7中没有。 If I remove the comments this will also work under XP good. 如果删除注释,则在XP下也可以使用。

any idea why? 知道为什么吗?

RadioButton rb1 = new RadioButton();
rb1.GroupName = kvp.Key.ToString();
rb1.Name = "Keep";
rb1.Margin = new Thickness(30, 5, 0, 0);
//rb1.HorizontalAlignment = HorizontalAlignment.Left;
//rb1.VerticalAlignment = VerticalAlignment.Top;
rb1.IsChecked = true;
rb1.Checked += OnRadioButton_Checked;
Grid.SetRow(rb1, grid.RowDefinitions.Count - 1);
Grid.SetColumn(rb1, 1);
grid.Children.Add(rb1);

Windows 7 and Windows XP will render the same XAML in slightly different ways because they have different default themes. Windows 7和Windows XP将以略有不同的方式呈现相同的XAML,因为它们具有不同的默认主题。 Vista and Windows 7 use Aero, while XP uses Luna (Windows Server 2003 uses Classic - Windows Server 2008 seems to as well). Vista和Windows 7使用Aero,而XP使用Luna(Windows Server 2003使用Classic-Windows Server 2008也是如此)。

You can override this to see if it is causing the differences you are seeing. 您可以覆盖它以查看是否引起您所看到的差异。

http://arbel.net/blog/archive/2006/11/03/Forcing-WPF-to-use-a-specific-Windows-theme.aspx http://arbel.net/blog/archive/2006/11/03/Forcing-WPF-to-use-a-specific-Windows-theme.aspx

http://msdn.microsoft.com/en-us/library/aa358533(v=VS.90).aspx http://msdn.microsoft.com/zh-CN/library/aa358533(v=VS.90).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM