这是XAML:
<Page
x:Class="App1.InputBoxPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Rectangle Fill="Black" Opacity="1"></Rectangle>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.3*"></RowDefinition>
<RowDefinition Height="0.4*"></RowDefinition>
<RowDefinition Height="0.3*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*"></ColumnDefinition>
<ColumnDefinition Width="0.4*"></ColumnDefinition>
<ColumnDefinition Width="0.3*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="0.7*"></RowDefinition>
<RowDefinition Height="0.1*"></RowDefinition>
<RowDefinition Height="0.2*"></RowDefinition>
</Grid.RowDefinitions>
<Image Source="/Image/MessageBox.png" VerticalAlignment="Top"></Image>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.1*"></ColumnDefinition>
<ColumnDefinition Width="0.3*"></ColumnDefinition>
<ColumnDefinition Width="0.2*"></ColumnDefinition>
<ColumnDefinition Width="0.3*"></ColumnDefinition>
<ColumnDefinition Width="0.1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" Content="OK" IsTabStop="False" HorizontalAlignment="Center" Name="InputBoxButtonYes">
<Button.Template>
<ControlTemplate>
<Grid Name="G">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Value="0.8" Target="G.Opacity"></Setter>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Image Source="/Image/MessageBoxButton.png"></Image>
<ContentPresenter FontSize="20" Foreground="#37f4ff" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></ContentPresenter>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
<Button Grid.Column="3" Content="Cancel" IsTabStop="False" HorizontalAlignment="Center" Name="InputBoxButtonNo">
<Button.Template>
<ControlTemplate>
<Grid Name="G">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Value="0.8" Target="G.Opacity"></Setter>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Image Source="/Image/MessageBoxButton.png" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<ScaleTransform ScaleX="-1"></ScaleTransform>
</Image.RenderTransform>
</Image>
<ContentPresenter FontSize="20" Foreground="#37f4ff" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></ContentPresenter>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*"></ColumnDefinition>
<ColumnDefinition Width="0.6*"></ColumnDefinition>
<ColumnDefinition Width="0.2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox Foreground="#FF37F4FF" Name="InputBoxContent" Background="#00FF0000" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" TextAlignment="Center" FontSize="15" BorderThickness="0,0,0,2" BorderBrush="#FF37F4FF" Template="{StaticResource TextBoxControlTemplate}"></TextBox>
<TextBlock Foreground="#17f98a" Name="InputBoxTitle" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="20" TextAlignment="Center">Input your code</TextBlock>
<!--<TextBox Grid.Column="1" Name="InputBoxContent"></TextBox>-->
</Grid>
</Grid>
</Grid>
</Grid>
</Page>
如上所述,我做了一个新页面。
当它运行时,结果是这样的:
如您所见,取消按钮的png不会呈现。
但是,当我调整窗口大小时,cancel的png成功呈现如下:
与此同时,我发现该错误没有规则,有时它会正确渲染,有时直到我调整窗口大小时才像我上面所说的那样渲染。
这是怎么回事?我几乎疯了,因为我什至不知道是什么诅咒。
答案 0 :(得分:0)
我按照@Johnny Westlake所说的做到了,删除了-1比例渲染变换并使用Photoshop翻转图像,然后将其添加到对象中。
完成后,我运行了几次,该错误不再发生。
看来确实是UWP中的错误,而Microsoft直到现在都没有修复它。
首先,最后,感谢@Johnny Westlake的帮助。
谢谢。