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
865
Vertical scroll/hide problem
posted

Normal 0 false false false EN-US X-NONE HE MicrosoftInternetExplorer4

Hi,


I need help to figure out why I don’t get a desired behavior from XamDataGrid sizing.

I want to have XamDataGrid to show all lines without vertical scrolling, because I want to enable zoom in/out on it from a slider and therefore I wrap it with “ScrollViewer”.

However what I get it enabled vertical scroll on both: XamDataGrid and ScrollViewer, where the grid is showing only 70 records out of 500.

As you can see I tried to wrap it with vertical StackPanel , hoping it will encourage XamDataGrid to grow vertically until all records are shown.

I also tried to calculate and set desired XamDataGrid height in code and it works, but very slow and inaccurate (each row can have different height).

I am out of ideas, please advice?

 

My XAML:

...

xmlns:my="clr-namespace:Infragistics.Windows.DataPresenter;assembly=Infragistics3.Wpf.DataPresenter.v9.2"

...

<ScrollViewer x:Name="scrollViewer" BorderBrush="Gray" BorderThickness="0.5"

                          DockPanel.Dock="Top" VerticalContentAlignment="Top"

                          VerticalScrollBarVisibility="Auto"

                          HorizontalScrollBarVisibility="Auto" PreviewMouseWheel="ScrollViewer_MouseWheel">

                <StackPanel Orientation="Vertical" VerticalAlignment="Top" Margin="3">

                    <my:XamDataGrid x:Name="xamGrid" DataSource="{Binding DiffResult.Rows}"

                                    GroupByAreaLocation="None"

                                    HorizontalAlignment="Left"

                                    Loaded="xamGrid_Loaded"

                                    IsNestedDataDisplayEnabled="False"

                                    AutoFit="True"

                                    Theme="Office2k7Silver"

                                    >

                        <my:XamDataGrid.FieldSettings>

                            <my:FieldSettings

                                AllowEdit="False"                                 

                                AllowRecordFiltering="True"

                                LabelClickAction="Nothing"

                                CellClickAction="EnterEditModeIfAllowed"

                                FilterOperandUIType="Combo"

                                FilterOperatorDropDownItems="Contains"

                                />

                        </my:XamDataGrid.FieldSettings>

                        <my:XamDataGrid.FieldLayoutSettings>

                            <my:FieldLayoutSettings

                                AllowAddNew="False"

                                AllowDelete="False"

                                AllowFieldMoving="No"

                                AutoGenerateFields="False"

                                FilterClearButtonLocation="RecordSelector"                   

                                />

                        </my:XamDataGrid.FieldLayoutSettings>

                        <my:XamDataGrid.LayoutTransform>

                            <ScaleTransform 

                                ScaleX="{Binding Path=Value, ElementName=zoomSlider}"

                                ScaleY="{Binding Path=Value, ElementName=zoomSlider}"/>

                        </my:XamDataGrid.LayoutTransform>

                        <my:XamDataGrid.Resources>

                            <Style TargetType="{x:Type my:DataRecordPresenter}">

                                <EventSetter Event="MouseEnter" Handler="DataRecordPresenter_MouseEnter"/>

                                <EventSetter Event="MouseLeave" Handler="DataRecordPresenter_MouseLeave"/>

                            </Style>                       

                        </my:XamDataGrid.Resources>

                    </my:XamDataGrid>

                </StackPanel>

        </ScrollViewer>

  • 54937
    Offline posted

    I would recommend reconsidering this approach. By making the control as large as required to show all the records, you are completely disabling any ability to virtualize. Note: this is not specific to us - virtualization is based upon the panel being provided a constraining size for its measure (i.e. knowing the size that the element will be) and being arranged at that size. In your set up, the elements within the scrollviewer are going to be measured with Infinity for the Width and Height. That will mean that every element required to show every record, cell, label, etc is going to get created, measured, arranged, etc. WPF is not designed to display large numbers of elements so depending on the number of elements (which in this case is going to be a product of the number of records you have and the number of non-collapsed fields), you could end up slowing down your app considerably (certainly at least for the initial load but even thereafter as changes occur) and possibly even crashing the app. This might be ok if you are certain to have a small number of records and fields but let's break it down for your example of 500 records. Using the default template for Aero, a vanilla XamDataGrid having 5 string fields will have 81 elements per DataRecordPresenter (i.e. per record). So if you have 500 records that's 40500 elements (plus you would have to add in a couple hundred more for the control itself, the labels, etc.).

    To answer your specific question, the reason that the grid is not showing all the records is that when it is measured with Infinity for the Width or Height, the grid will first look at its ViewSettings->(Height|Width)InInfiniteContainers. If the associated property is set, it will use that value. If it is not set then it will use the virtual screen width/height so you can set these properties to a large value to control what constraining value it will use when measured in with infinity.