/// <summary> /// Config Visibility, and pageSize. /// </summary> /// <param name="gp"> /// The gp. /// </param> private static void ConfigureValoresInternos(PagingControl gp) { // Set the Total de paginas.... gp.lTotalPages.Content = gp.TotalPages; // Set the pageSize control foreach (ComboBoxItem comboBoxItem in gp.cbPageSize.Items) { int cbi = Convert.ToInt32(comboBoxItem.Content); if (cbi == gp.PageSize) { gp.cbPageSize.SelectedItem = comboBoxItem; break; } } // if the setted value in Page size is not in list, return to original value. ComboBoxItem sel = (ComboBoxItem)gp.cbPageSize.SelectedItem; gp.PageSize = Convert.ToInt32(sel.Content); // Set the visibility of Pagination Buttons. gp.ButtonGrid.Visibility = gp.TotalCount > gp.PageSize ? Visibility.Visible : Visibility.Hidden; // Calculate the HasNextPage and previous page gp.HasPreviousPage = gp.PageIndex > 1; gp.HasNextPage = gp.TotalPages > gp.PageIndex; }
/// <summary> /// Evento cuando cambia la cantidad total de Registros. /// </summary> /// <param name="d"> /// The d. /// </param> /// <param name="e"> /// The e. /// </param> private static void PropertyTotalCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // Update Total Count label.... PagingControl gp = (PagingControl)d; gp.lTotal.Content = e.NewValue; ConfigureValoresInternos(gp); }
/// <summary> /// Change the Page Size Property control. /// This make that PageIndex go to 1. /// </summary> /// <param name="d"> /// The d. /// </param> /// <param name="e"> /// The e. /// </param> private static void PropertyPageSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PagingControl gp = (PagingControl)d; // int pagesize = (int)e.NewValue; ConfigureValoresInternos(gp); gp.PageIndex = 1; }
/// <summary> /// Evento para actualizar el page index. /// </summary> /// <param name="d"> /// The d. /// </param> /// <param name="e"> /// The e. /// </param> private static void PropertyPageIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // Update Total Count label.... PagingControl gp = (PagingControl)d; int actualPage = (int)e.NewValue; gp.lActualPage.Content = actualPage; ConfigureValoresInternos(gp); }