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
30
Set a minimum size for Infragistics Controls but allow it to grow with window size.
posted

I've started swapping some Windows controls with Infragistics controls and I'm having some difficulty with sizing. Currently my Main Window starts with a default minimum size. The Main Window is set to grow with the content. I'll use the XamDataGrid as an example. In design time the datagrid fits the minimum size and looks correct, however when running the application it enlarges the window to accommodate the entire grid instead of adding scrollbars. Is there a way to set a starting size for the datagrid but also have it grow when the window is resized?

Thanks

  • 28925
    Offline posted

    Hello Adam, 

    I recommend placing the XamDataGrid inside a DockPanel if you want it to grow as the window does. There is no initial width or height that can be set. This would be applicable to any control.

    Please provide some xaml related to the XamDataGrid and it's parent element/container to provide some context about the behavior you seek. Note, if the XamDataGrid is inside a container, eg. StackPanel, that has an infinite height, then it's expected that scrolling vertically won't work unless you set the grid's ViewSettings.HeightInInfiniteContainers property equal to the height of the grid or if you use something like a DockPanel instead as the container, possibly.

    The XamDataGrid specifically should show scrollbars when needed, but you can get it to forcefully show scrollbars with the following style. 

    Let me know if you have any questions.

    <DockPanel VerticalAlignment="Stretch" >
                <igWPF:XamDataGrid VerticalContentAlignment="Stretch"  Name="dataGrid2" DataSource="{Binding}" 
                                  Loaded="dataGrid2_Loaded">
                    <igWPF:XamDataGrid.Resources>
                        <Style TargetType="{x:Type igWPF:RecordListControl}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type igWPF:RecordListControl}">
                                        <ScrollViewer
                Focusable="true"
                CanContentScroll="True"            
                HorizontalScrollBarVisibility="Visible"
                VerticalScrollBarVisibility="Visible">
                                            <ItemsPresenter/>
                                        </ScrollViewer>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </igWPF:XamDataGrid.Resources>
                </igWPF:XamDataGrid>
            </DockPanel>


    XamDataGrid_sample (DockPanel).zip