Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make scrollviewer work with Height set to Auto in WPF?
    primarykey
    data
    text
    <p>I have learned that if the height of a grid row, where the <code>ScrollViewer</code> resides, is set as <code>Auto</code>, the vertical scroll bar will not take effect since the actual size of the <code>ScrollViewer</code> can be larger than the height in sight. So in order to make the scroll bar work, I should set the height to either a fixed number or star height</p> <p>However, I now have this requirement, that I have two different views reside in two grid rows, and I have a toggle button to switch between these two views: when one view is shown, the other one is hidden/disappeared. So I have defined two rows, both heights are set as <code>Auto</code>. And I bind the visibility of the view in each row to a boolean property from my ViewModel (one is converted from <code>True</code> to <code>Visible</code> and the other from <code>True</code> to <code>Collapsed</code>. The idea is when one view's visibility is <code>Collapsed</code>, the height of the grid row/view will be changed to 0 automatically.</p> <p>The view show/hidden is working fine. However, in one view I have a <code>ScrollViewer</code>, which as I mentioned doesn't work when the row height is set as <code>Auto</code>. Can anybody tell me how I can fulfill such requirement while still having the <code>ScrollViewer</code> working automatically`? I guess I can set the height in code-behind. But since I am using MVVM, it would require extra communication/notification. Is there a more straightforward way to do that? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload