When I am running this code in Windows XP I get a rectangle around the radiobutton. In windows 7 not. If I remove the comments this will also work under XP good.
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 = H开发者_开发问答orizontalAlignment.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. Vista and Windows 7 use Aero, while XP uses Luna (Windows Server 2003 uses Classic - Windows Server 2008 seems to as well).
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://msdn.microsoft.com/en-us/library/aa358533(v=VS.90).aspx
精彩评论