0

私はグリッドを持っています。このグリッドは、アイテムがエキスパンダーであるリストボックスを保持するスクロールビューアーを保持します。UserControl の垂直方向の高さを超えるまでエキスパンダーを展開すると、スクロールビューアーのスクロールバーが正しく表示されます。エキスパンダーをもう一度折りたたむと、スクロールビューアーのスクロールバーは同じままです! 予想されるように、再び縮小したり消えたりすることはありません。

すでにいくつかの異なるグリッド行設定 (「自動」、「*」) と異なる垂直配置設定 (上、ストレッチ、...) を試しました。

エキスパンダーを折りたたんだ後、スクロールビューアーを再び縮小するにはどうすればよいですか?

<UserControl x:Class="Expanderin_Scroller.MainPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d"
             d:DesignWidth="440"
             d:DesignHeight="300">

  <Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <ScrollViewer x:Name="ScrToolbox"
                  Grid.Row="1"
                  VerticalAlignment="Top">
      <ListBox x:Name="Toolbox">
        <telerik:RadExpander Header="Expander 1">
          <StackPanel>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
          </StackPanel>
        </telerik:RadExpander>

        <telerik:RadExpander Header="Expander 2">
          <StackPanel>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
          </StackPanel>
        </telerik:RadExpander>

        <telerik:RadExpander Header="Expander 3">
          <StackPanel>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
          </StackPanel>
        </telerik:RadExpander>

        <telerik:RadExpander Header="Expander 4">
          <StackPanel>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
            <TextBlock>Hello</TextBlock>
          </StackPanel>
        </telerik:RadExpander>
      </ListBox>
    </ScrollViewer>
  </Grid>
</UserControl>
4

1 に答える 1

0

Telerik の連中の助けを借りて、この問題を解決できました。

この問題は、ListBox の動作、特にその ItemsPanel が原因で発生します。ListBox のサイズとそのコンテンツのサイズを更新するには、ListBox.ItemsPanel を StackPanel に設定します。

<ListBox.ItemsPanel>
     <ItemsPanelTemplate>
          <StackPanel />
     </ItemsPanelTemplate>
</ListBox.ItemsPanel>

リストボックスのサイズがコンテンツに合わせて変更されるようになりました。

于 2013-04-23T07:04:49.420 に答える