Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

DragablzItemsControl size

Abierto
#3 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
desktop

Línea de trabajo

Comienza con DragablzItemsControl.MeasureOverride y las llamadas de medición de ItemsOrganiser que se muestran en el issue. Reproduce el control con diferentes cantidades de elementos y una altura restringida; se considera terminado cuando crece con su contenido hasta alcanzar la restricción, después de lo cual aparece el desplazamiento.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hi,
Thank you for example, it looks cool and we’d like to implement it.
I’ve got one problem that I can’t get around until I modify one of your methods (which I don’t want to do until I must).
Basically, I want the DragablzItemsControl to start on as high as it need to be, and then as we add more records it should grow, until it reaches it maxheight then the scrollbar should appear. Instead the DragablzItemsControl height is the max from the beginning which can be seen if you change the background to a different color.
So, I noticed that the problems comes from here

   protected override Size MeasureOverride(Size constraint)
   {
        if (ItemsOrganiser == null) return base.MeasureOverride(constraint);

        if (LockedMeasure.HasValue)
        {
            ItemsPresenterWidth = LockedMeasure.Value.Width;
            ItemsPresenterHeight = LockedMeasure.Value.Height;
            return LockedMeasure.Value;
        }

        var dragablzItems = DragablzItems().ToList();
        var maxConstraint = new Size(double.PositiveInfinity, double.PositiveInfinity);

        ItemsOrganiser.Organise(this, maxConstraint, dragablzItems);
        var measure = ItemsOrganiser.Measure(this, new Size(ActualWidth, ActualHeight), dragablzItems);

        ItemsPresenterWidth = measure.Width;
        ItemsPresenterHeight = measure.Height;

        var width = double.IsInfinity(constraint.Width) ? measure.Width : constraint.Width;
        var height = double.IsInfinity(constraint.Height) ? measure.Height : constraint.Height;

        return new Size(width, height);
    }

The constraint width or height are never infinity, so these values always come back as constraint values. My fix is this

    protected override Size MeasureOverride(Size constraint)
    {
        if (ItemsOrganiser == null) return base.MeasureOverride(constraint);

        if (LockedMeasure.HasValue)
        {
            ItemsPresenterWidth = LockedMeasure.Value.Width;
            ItemsPresenterHeight = LockedMeasure.Value.Height;
            return LockedMeasure.Value;
        }

        var dragablzItems = DragablzItems().ToList();
        var maxConstraint = new Size(double.PositiveInfinity, double.PositiveInfinity);

        ItemsOrganiser.Organise(this, maxConstraint, dragablzItems);
        var measure = ItemsOrganiser.Measure(this, new Size(ActualWidth, ActualHeight), dragablzItems);

        ItemsPresenterWidth = measure.Width;
        ItemsPresenterHeight = measure.Height;

        var width = double.IsInfinity(constraint.Width) || (dragablzItems.Count > 0 && constraint.Width > measure.Width) ? measure.Width : constraint.Width;
        var height = double.IsInfinity(constraint.Height) || (dragablzItems.Count > 0 && constraint.Height > measure.Height) ? measure.Height : constraint.Height;

        return new Size(width, height);
    }

This way the itemscontrol always becomes as big as it needs to be for a given number of items, until it is bigger than the constraint then it does not grow any bigger and the scrollbar appears.
Hopefully it makes sense, is it possible for you to implement something like this, or is it a case that I must override this method in a derived class of my own?

Thank you

Lenguaje dominante
C#
Estrellas
248
Forks
40
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Aún no hemos revisado los archivos de configuración de este proyecto. Empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MaterialDesignInXAML/MotionList

Todos los issues de MaterialDesignInXAML/MotionList

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.