<Window x:Class="TestProject.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:TestProject"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<!--The following code snippets go here-->
</Window>
<Grid>
<Grid x:Name="myGrid" Width="200" Height="100" Background="Green">
<Grid.LayoutTransform>
<ScaleTransform ScaleX="3" ScaleY="1" CenterX=".5" CenterY=".5"></ScaleTransform>
</Grid.LayoutTransform>
</Grid>
</Grid>
实际:
myGrid.RenderSize
{200,100}
Height: 100
IsEmpty: false
Width: 200
myGrid.DesiredSize
{600,100}
Height: 100
IsEmpty: false
Width: 600
预期:
myGrid.RenderSize
{200,100}
Height: 100
IsEmpty: false
Width: 600
myGrid.DesiredSize
{600,100}
Height: 100
IsEmpty: false
Width: 600
<Grid>
<Grid x:Name="myGrid" Width="200" Height="100" Background="Green">
<Grid.RenderTransform>
<ScaleTransform ScaleX="3" ScaleY="1" CenterX=".5" CenterY=".5"></ScaleTransform>
</Grid.RenderTransform>
</Grid>
</Grid>
实际:
myGrid.RenderSize
{200,100}
Height: 100
IsEmpty: false
Width: 200
myGrid.DesiredSize
{200,100}
Height: 100
IsEmpty: false
Width: 200
预期:
myGrid.RenderSize
{200,100}
Height: 100
IsEmpty: false
Width: 600
myGrid.DesiredSize
{200,100}
Height: 100
IsEmpty: false
Width: 200
<Viewbox Stretch="UniformToFill">
<Grid x:Name="myGrid" Width="200" Height="100" Background="Green"></Grid>
</Viewbox>
实际:
myGrid.RenderSize
{200,100}
Height: 100
IsEmpty: false
Width: 200
myGrid.DesiredSize
{200,100}
Height: 100
IsEmpty: false
Width: 200
预期:
不确定,如果Viewbox使用RenderTransform
,那么我希望myGrid.RenderSize.Width
是600
,而myGrid.DesiredSize.Width
是200
,否则,如果Viewbox使用{{ 1}},那么我期望LayoutTransform
和myGrid.RenderSize.Width
为myGrid.DesiredSize.Width
。
我基于以下布局过程阶段得出预期结果:
600
,并且Desired with是600,为什么“ Rendered Width”还是200?谢谢。