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
4970
Custom Pager Style problem for XamGrid
posted

Try to create a custome pager for Xamgrid.  What I did as bellow:
1. Create a style like:
    <Style x:Key="TestPager" TargetType="gridPrim:PagerCellControl" >
        <Setter  Property="Template">
            <Setter.Value >
                <ControlTemplate TargetType="gridPrim:PagerCellControl">
                    <StackPanel  Orientation="Horizontal" HorizontalAlignment="Right" >
                        <StackPanel Orientation="Horizontal">
                            <Button x:Name="TestButton" Margin="25,0,5,0" Padding="2" Height="20" >
                                <Button.Content>
                                    <Image Source="MyTest.png" Height="16" Cursor="Hand"  />
                                </Button.Content>
                                <ig:Commanding.Command>
                                    <common:TestCommandSource EventName="Click"/>
                                </ig:Commanding.Command>
                            </Button >

                            <TextBlock Text="Page Size:" Margin="15,8,5,0"></TextBlock>
                            ......    

                        </StackPanel>
                        <gridPrim:PagerControl x:Name="PagerItemControl">
                            <ig:Commanding.Commands>
                                <ig:XamGridPagingCommandSource EventName="FirstPage"  CommandType="FirstPage"/>
                                <ig:XamGridPagingCommandSource EventName="LastPage"  CommandType="LastPage"/>
                                <ig:XamGridPagingCommandSource EventName="PreviousPage"  CommandType="PreviousPage"/>
                                <ig:XamGridPagingCommandSource EventName="NextPage"  CommandType="NextPage"/>
                                <ig:XamGridPagingCommandSource EventName="GoToPage"  CommandType="GoToPage" />
                            </ig:Commanding.Commands>
                        </gridPrim:PagerControl>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter >
    </Style>
2. Create XamGrid in user control testing the pager with following Settings:
    <ig:XamGrid.RowSelectorSettings>
        <ig:RowSelectorSettings x:Name="rowSelectorSettings" Visibility="Visible" />
    </ig:XamGrid.RowSelectorSettings>
    <ig:XamGrid.FilteringSettings>
        <ig:FilteringSettings AllowFiltering="FilterRowTop" IsMouseActionEditingEnabled="SingleClick" FilteringScope="ColumnLayout"/>
    </ig:XamGrid.FilteringSettings>
    <ig:XamGrid.PagerSettings>
        <ig:PagerSettings AllowPaging="top"  Style="{StaticResource TestPager}" />
    </ig:XamGrid.PagerSettings>
    <ig:XamGrid.ClipboardSettings>
        <ig:ClipboardSettings AllowCopy="True" AllowPaste="True"/>
    </ig:XamGrid.ClipboardSettings>
    <ig:XamGrid.SortingSettings>
        <ig:SortingSettings AllowMultipleColumnSorting="True" />
    </ig:XamGrid.SortingSettings>
    <ig:XamGrid.ColumnMovingSettings>
        <ig:ColumnMovingSettings AllowColumnMoving="Indicator"/>
    </ig:XamGrid.ColumnMovingSettings>
    <ig:XamGrid.SelectionSettings>
        <ig:SelectionSettings CellSelection="Multiple" ColumnSelection="Multiple" RowSelection="Multiple" CellClickAction="SelectRow" />
    </ig:XamGrid.SelectionSettings>
    <ig:XamGrid.ColumnChooserSettings>
        <ig:ColumnChooserSettings AllowHideColumnIcon="True" AllowHiddenColumnIndicator="True"></ig:ColumnChooserSettings>
    </ig:XamGrid.ColumnChooserSettings>
    <ig:XamGrid.ColumnResizingSettings>
        <ig:ColumnResizingSettings AllowColumnResizing="Indicator" AllowMultipleColumnResize="True" AllowCellAreaResizing="True" AllowDoubleClickToSize="True" />
    </ig:XamGrid.ColumnResizingSettings>
    <ig:XamGrid.ConditionalFormattingSettings>
        <ig:ConditionalFormattingSettings AllowConditionalFormatting="True" />
    </ig:XamGrid.ConditionalFormattingSettings>
    <ig:PersistenceManager.Settings>
        <ig:PersistenceSettings SavePersistenceOptions="AllButIgnored"
                                        LoadPersistenceOptions="AllButIgnored">
            <ig:PersistenceSettings.PropertySettings>
                <ig:PropertyNamePersistenceInfo PropertyName="Columns[].FilterColumnSettings"
                                                Options="Contains"/>
            </ig:PersistenceSettings.PropertySettings>
        </ig:PersistenceSettings>
    </ig:PersistenceManager.Settings>

3. Binding for ItemSoutce of XamGrid is PagedCollectionView  in view model:
in VM:
public PagedCollectionView DataList { get; set; }

in Xaml:
ItemsSource="{Binding DataList}"


4. Run the app with no data, click on the button in pager: first click will do nothing but move the mouse cursor to the filter line in XamGrid, second click will call the command assoicated with the button.

5. If there is try to test this case with Restore persistence, when Usercontrol UI is loaded with no data, the header line of XamGrid lost and may crash tha app.

So looks like if there is no data for XamGrid, there is a lot of problem. How to fix it so that it working well for different situation?