Why does the RenderSize of a Grid stay the same in all three of these cases?










1















<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>


Example 1



<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>


Actual:



myGrid.RenderSize
200,100
    Height: 100
    IsEmpty: false
    Width: 200

myGrid.DesiredSize
600,100
    Height: 100
    IsEmpty: false
    Width: 600


Expected:



myGrid.RenderSize
200,100
    Height: 100
    IsEmpty: false
    Width: 600

myGrid.DesiredSize
600,100
    Height: 100
    IsEmpty: false
    Width: 600


Example 2



<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>


Actual:



myGrid.RenderSize
200,100
    Height: 100
    IsEmpty: false
    Width: 200

myGrid.DesiredSize
200,100
    Height: 100
    IsEmpty: false
    Width: 200


Expected:



myGrid.RenderSize
200,100
    Height: 100
    IsEmpty: false
    Width: 600

myGrid.DesiredSize
200,100
    Height: 100
    IsEmpty: false
    Width: 200


Example 3



<Viewbox Stretch="UniformToFill">
<Grid x:Name="myGrid" Width="200" Height="100" Background="Green"></Grid>
</Viewbox>


Actual:



myGrid.RenderSize
200,100
    Height: 100
    IsEmpty: false
    Width: 200
myGrid.DesiredSize
200,100
    Height: 100
    IsEmpty: false
    Width: 200


Expected:



Not sure, if Viewbox uses RenderTransform then I would expect myGrid.RenderSize.Width to be 600 and myGrid.DesiredSize.Width to be 200, otherwise if Viewbox uses LayoutTransform then I would expect myGrid.RenderSize.Width and myGrid.DesiredSize.Width to be 600.




I am basing my expected results based on the following layout process stages:



  1. LayoutTransform

  2. Measure - DesiredSize of each element is computer here

  3. Arrange - Position of child elements within their parents is determined

  4. RenderTransform

  5. Render - RenderSize is computer here, elements are rendered to the screen

Questions:



  • Does Viewbox apply RenderTransform or LayoutTransform?

  • How does RenderTransform change the element such that RenderSize dimensions do not change?

  • For example 1, why is Rendered Width is 200, even though LayoutTransform is applied to myGrid and the Desired with is 600?

Thank you in advance.










share|improve this question


























    1















    <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>


    Example 1



    <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>


    Actual:



    myGrid.RenderSize
    200,100
        Height: 100
        IsEmpty: false
        Width: 200

    myGrid.DesiredSize
    600,100
        Height: 100
        IsEmpty: false
        Width: 600


    Expected:



    myGrid.RenderSize
    200,100
        Height: 100
        IsEmpty: false
        Width: 600

    myGrid.DesiredSize
    600,100
        Height: 100
        IsEmpty: false
        Width: 600


    Example 2



    <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>


    Actual:



    myGrid.RenderSize
    200,100
        Height: 100
        IsEmpty: false
        Width: 200

    myGrid.DesiredSize
    200,100
        Height: 100
        IsEmpty: false
        Width: 200


    Expected:



    myGrid.RenderSize
    200,100
        Height: 100
        IsEmpty: false
        Width: 600

    myGrid.DesiredSize
    200,100
        Height: 100
        IsEmpty: false
        Width: 200


    Example 3



    <Viewbox Stretch="UniformToFill">
    <Grid x:Name="myGrid" Width="200" Height="100" Background="Green"></Grid>
    </Viewbox>


    Actual:



    myGrid.RenderSize
    200,100
        Height: 100
        IsEmpty: false
        Width: 200
    myGrid.DesiredSize
    200,100
        Height: 100
        IsEmpty: false
        Width: 200


    Expected:



    Not sure, if Viewbox uses RenderTransform then I would expect myGrid.RenderSize.Width to be 600 and myGrid.DesiredSize.Width to be 200, otherwise if Viewbox uses LayoutTransform then I would expect myGrid.RenderSize.Width and myGrid.DesiredSize.Width to be 600.




    I am basing my expected results based on the following layout process stages:



    1. LayoutTransform

    2. Measure - DesiredSize of each element is computer here

    3. Arrange - Position of child elements within their parents is determined

    4. RenderTransform

    5. Render - RenderSize is computer here, elements are rendered to the screen

    Questions:



    • Does Viewbox apply RenderTransform or LayoutTransform?

    • How does RenderTransform change the element such that RenderSize dimensions do not change?

    • For example 1, why is Rendered Width is 200, even though LayoutTransform is applied to myGrid and the Desired with is 600?

    Thank you in advance.










    share|improve this question
























      1












      1








      1








      <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>


      Example 1



      <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>


      Actual:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200

      myGrid.DesiredSize
      600,100
          Height: 100
          IsEmpty: false
          Width: 600


      Expected:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 600

      myGrid.DesiredSize
      600,100
          Height: 100
          IsEmpty: false
          Width: 600


      Example 2



      <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>


      Actual:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200

      myGrid.DesiredSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200


      Expected:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 600

      myGrid.DesiredSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200


      Example 3



      <Viewbox Stretch="UniformToFill">
      <Grid x:Name="myGrid" Width="200" Height="100" Background="Green"></Grid>
      </Viewbox>


      Actual:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200
      myGrid.DesiredSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200


      Expected:



      Not sure, if Viewbox uses RenderTransform then I would expect myGrid.RenderSize.Width to be 600 and myGrid.DesiredSize.Width to be 200, otherwise if Viewbox uses LayoutTransform then I would expect myGrid.RenderSize.Width and myGrid.DesiredSize.Width to be 600.




      I am basing my expected results based on the following layout process stages:



      1. LayoutTransform

      2. Measure - DesiredSize of each element is computer here

      3. Arrange - Position of child elements within their parents is determined

      4. RenderTransform

      5. Render - RenderSize is computer here, elements are rendered to the screen

      Questions:



      • Does Viewbox apply RenderTransform or LayoutTransform?

      • How does RenderTransform change the element such that RenderSize dimensions do not change?

      • For example 1, why is Rendered Width is 200, even though LayoutTransform is applied to myGrid and the Desired with is 600?

      Thank you in advance.










      share|improve this question














      <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>


      Example 1



      <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>


      Actual:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200

      myGrid.DesiredSize
      600,100
          Height: 100
          IsEmpty: false
          Width: 600


      Expected:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 600

      myGrid.DesiredSize
      600,100
          Height: 100
          IsEmpty: false
          Width: 600


      Example 2



      <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>


      Actual:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200

      myGrid.DesiredSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200


      Expected:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 600

      myGrid.DesiredSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200


      Example 3



      <Viewbox Stretch="UniformToFill">
      <Grid x:Name="myGrid" Width="200" Height="100" Background="Green"></Grid>
      </Viewbox>


      Actual:



      myGrid.RenderSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200
      myGrid.DesiredSize
      200,100
          Height: 100
          IsEmpty: false
          Width: 200


      Expected:



      Not sure, if Viewbox uses RenderTransform then I would expect myGrid.RenderSize.Width to be 600 and myGrid.DesiredSize.Width to be 200, otherwise if Viewbox uses LayoutTransform then I would expect myGrid.RenderSize.Width and myGrid.DesiredSize.Width to be 600.




      I am basing my expected results based on the following layout process stages:



      1. LayoutTransform

      2. Measure - DesiredSize of each element is computer here

      3. Arrange - Position of child elements within their parents is determined

      4. RenderTransform

      5. Render - RenderSize is computer here, elements are rendered to the screen

      Questions:



      • Does Viewbox apply RenderTransform or LayoutTransform?

      • How does RenderTransform change the element such that RenderSize dimensions do not change?

      • For example 1, why is Rendered Width is 200, even though LayoutTransform is applied to myGrid and the Desired with is 600?

      Thank you in advance.







      c# .net wpf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 18:13









      afl aflavichafl aflavich

      83




      83






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325565%2fwhy-does-the-rendersize-of-a-grid-stay-the-same-in-all-three-of-these-cases%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325565%2fwhy-does-the-rendersize-of-a-grid-stay-the-same-in-all-three-of-these-cases%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto