Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
495
Scrollbar appears instead of shrinking grid
posted

Hi

I use a xamDataGrid. I set AutoFit=true and and AllowResize=true on some FieldSettings. Around my Grid I placed a ScrollViewer. MinWidth of the Grid is set to its initial value.

At first everything seems fine. If I decrease the size of my window (which contains the grid) the scrollbar appears. Then if I increase the size of the window the grid and its columns stretches as expected. So far so good.

However, if I increase the size first the grid stretches as expected but then if I decrease the size the scrollbar appears. I would like to have the grid shrinking until it reaches its MinWidth before the scrollbar would appear... Can I do that?

  • 27093
    posted

    Hello Dunken,

     

    I have been looking into your requirement and this is rather expected, since when a control is placed inside a ScrolViewer, there isn’t a boundary that would confine him in any side, but rather the ScrollViewer’s ScrollBars are visualized to enable scrolling through the taken space. Usually the a simple control would not fit the ScrollViewer in the first place as the AutoFitted XamDataGrid does, however the XamDataGrid’ template is quite complex and also contains a ScrollViewer inside itself. This is why in order for you to achieve the desired functionality I can suggest using the built-in ScrollViewer and the supported functionality like so:

     

    <igDP:XamDataGrid BindToSampleData="True" AutoFit="True" >

        <igDP:XamDataGrid.FieldSettings>

            <igDP:FieldSettings LabelMinWidth="50" />

        </igDP:XamDataGrid.FieldSettings>

    </igDP:XamDataGrid>

     

    This code will allow the auto-fitting until the Fields reach their minimum widths when the inner HorizontalScrollbar will appear. For this particular snippet the whole MinWidth would sum up to 4x50 for the four Fields + 20 for the RecordSelector element.

     

    Please let me know if I can be of any further assistance on the matter.