在Windows XP上强制显示WPF主窗口的Vista样式,可以通过以下步骤实现:
using System.Windows.Forms;
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.ClientAndNonClientAreasEnabled;
}
}
using System.Windows.Forms;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Loaded += MainWindow_Loaded;
}
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.ClientAndNonClientAreasEnabled;
}
}
using System.Windows.Forms;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Loaded += MainWindow_Loaded;
}
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.ClientAndNonClientAreasEnabled;
}
}
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
这样,在Windows XP上运行WPF主窗口时,就会强制显示Vista样式了。
领取专属 10元无门槛券
手把手带您无忧上云