1

モードを「リサイクル」に設定してVirtualizingStackPanelを使用するカスタムコントロールに取り組んでおり、次の問題に遭遇しました: http://i.imgur.com/XoarX.png

しばらく列幅を「遊んで」からウィンドウを最大化すると発生します。何が原因なのかわかりません。PrepareContainerForItemOverride が呼び出され、セルの幅を確認しましたが、正しいです。セルを保持する StackPanel が内容を再配置していないようで、強制的に再配置する方法がわかりません...

あまり詳しく説明していないことは承知していますが、同様の問題を抱えていて、たまたま解決策を知っている人もいるかもしれません。

編集: 関連部分の XAML:

<Style x:Key="{x:Type dgp:CellsPresenter}" TargetType="{x:Type dgp:CellsPresenter}">
    <Setter Property="ItemsPanel">
        <Setter.Value>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type dgp:CellsPresenter}">
                <ItemsPresenter/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style x:Key="{x:Type dg:Cell}" TargetType="{x:Type dg:Cell}">
    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" />
    <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
    <Setter Property="BorderThickness" Value="0,0,1,1" />

    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type dg:Cell}">
                <Border Background="{TemplateBinding Background}" 
              BorderBrush="{TemplateBinding BorderBrush}"  
              BorderThickness="{TemplateBinding BorderThickness}" 
              SnapsToDevicePixels="True">
                    <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                      HorizontalAlignment="Center"
                                      VerticalAlignment="Center"/>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Style.Triggers>
        <Trigger Property="IsSelected" Value="True">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
        </Trigger>
    </Style.Triggers>
</Style>

各行 (単純なコントロール、XAML とは無関係) は CellPresenter を保持し、行は VirtualizingStackPanel にスタックされます。ItemsPanelTemplate で確認できる水平方向の StackPanel のレイアウトが更新されていないようです。

4

0 に答える 0