Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

DragablzItemsControl size

オープン
#3 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp
領域
desktop

調査の方向性

DragablzItemsControl.MeasureOverride と、issue に示されている ItemsOrganiser の測定呼び出しから始めます。異なる項目数と高さの制約でコントロールを再現します。制約に達するまではコンテンツに合わせて拡大し、その後スクロールが表示されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
C#
スター
248
フォーク
40
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MaterialDesignInXAML/MotionList のほかの issue

MaterialDesignInXAML/MotionList の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。