2010-01-06 2 views
0

ItemTemplate에 대해 DataTemplate을 사용하여 ListBox에 표시하는 다양한 컬렉션 속성이있는 일부 개체가 있습니다. DataTemplate 내에는 ListBoxItem에 표시되는 항목을 나타내는 루트 TreeViewItem의 TreeViewItem 하위 항목으로 다양한 속성을 표시하는 TreeView가 있습니다. 내 문제는 : ListBoxItems는 DataTemplate 내에서 완전히 확장 된 TreeView의 세로 크기를가집니다. ListBoxItems가 가능한 최소 크기를 갖도록 변경할 수 있습니까?WPF TreeView는 루트 루트 축소시 이전에 사용 된 공간을 축소하지 않습니다.

내 XAML

: 나는 윈도우의 모든 ScrollViewers의 최소 높이와 너비를 정의 된 윈도우 자원 정의에서 ScrollViewer의 스타일을 가지고, 내가 ListBoxItems이 ScrollViewers를 사용하는 것이 몰랐어요

<ListBox x:Name="ShackList" ItemsSource="{Binding}" ToolTip="Right click for options" SelectionMode="Single"> 
    <ListBox.ItemTemplate> 
    <DataTemplate DataType="{x:Type model:ShackConfigurationRepository}"> 
     <TreeView BorderThickness="0" Margin="0"> 
     <TreeView.Resources> 
      <Style x:Key="deviceRepoNodeStyle" TargetType="{x:Type TreeViewItem}"> 
      <Setter Property="Margin" Value="3"/> 
      <Setter Property="ContextMenu" Value="{StaticResource deviceTypeTreeViewItemContextMenu}"/> 
      </Style> 
     </TreeView.Resources> 
     <TreeViewItem> 
      <TreeViewItem.Header> 
      <StackPanel Orientation="Horizontal"> 
       <Image Source="Resources/Shack_64x64_72.png" Height="24" Width="24"/> 
       <TextBlock VerticalAlignment="Center" Margin="5,0,0,0" Text="{Binding Path=ShackName}" /> 
      </StackPanel> 
      </TreeViewItem.Header> 
      <!-- 
      The 'Tag' attribute of the following TreeViewItems is a value of 
      DeviceType used to control which collection gets set as the content 
      of the device list. 
      --> 
      <TreeViewItem Header="Pendants" Tag="PENDANT"  Selected="ShackDevice_Selected" DataContext="{Binding}" Style="{StaticResource deviceRepoNodeStyle}" PreviewMouseRightButtonDown="DeviceTreeNode_PreviewMouseRightButtonDown"/> 
      <TreeViewItem Header="Oscillators" Tag="OSCILLATOR" Selected="ShackDevice_Selected" DataContext="{Binding}" Style="{StaticResource deviceRepoNodeStyle}" PreviewMouseRightButtonDown="DeviceTreeNode_PreviewMouseRightButtonDown"/> 
      <TreeViewItem Header="Thru-Arc-Tracking" Tag="TAT" Selected="ShackDevice_Selected" DataContext="{Binding}" Style="{StaticResource deviceRepoNodeStyle}" PreviewMouseRightButtonDown="DeviceTreeNode_PreviewMouseRightButtonDown"/> 
      <TreeViewItem Header="Travel" Tag="TRAVEL"   Selected="ShackDevice_Selected" DataContext="{Binding}" Style="{StaticResource deviceRepoNodeStyle}" PreviewMouseRightButtonDown="DeviceTreeNode_PreviewMouseRightButtonDown"/> 
     </TreeViewItem> 
     </TreeView> 
    </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

답변

0

내부적으로.