【发布时间】:2021-10-17 02:41:51
【问题描述】:
出于某种原因,我计算机上 WPF 上的按钮在 VS2019 编辑器和应用程序内(无论是调试模式还是发布模式)看起来都很奇怪和陈旧。我尝试创建一个新项目/解决方案,将样式更改为“Style="{x:Null}",卸载更改我的 Windows 设计的应用程序(例如 open shell 或雨量计),但它们看起来仍然陈旧而奇怪我的电脑。 唯一有效的是在另一台计算机上测试我的应用程序,我的应用程序(在发布模式下)看起来应该,但它在我的计算机上仍然看起来很奇怪,并且让我很难预览应用程序的外观(并且还使该应用在我的 PC 上看起来很丑)。
我能做什么?
如果需要,这里是 XAML:
<Window x:Class="WPFApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="100"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Content="My Button" Grid.Row="1" Grid.Column="1"/>
</Grid>
【问题讨论】:
-
您还没有解释为什么按钮应该看起来不同。具有默认模板的按钮在不同计算机上看起来不同的事实可以通过以下事实来解释:所有元素的默认模板不是由 Windows 操作系统本身设置的,而是由这台特定计算机上使用的主题设置的。如果主题不同,则元素看起来可能不同。
标签: c# .net wpf windows visual-studio