2012-03-01 4 views
0

У меня есть этот XAML, где я пытался получить содержимое TabItem для прокрутки (без успеха).Содержимое Silverlight TabItem не прокручивается

<ex:TabControl> 
    <ex:TabItem Header="General"> 
    <ContentPresenter Content="{Binding }" ContentTemplate="{StaticResource tabMenuItem}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" /> 
    </ex:TabItem> 
    <ex:TabItem Header="Prices (Item)"> 
    <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto"> 
     <ContentPresenter Content="{Binding NonModifierPricesView}" ContentTemplate="{StaticResource tabMenuItemPrices}" /> 
    </ScrollViewer> 
    </ex:TabItem> 
</ex:TabControl> 

Когда мой TabControl получает изменен так, что TabItem слишком мал, чтобы отобразить все содержимое, не отображаются полосы прокрутки. Я что-то сделал что-то не так?

Edit: Запрошенный XAML для tabMenuItemPrices

<DataTemplate x:Key="tabMenuItemPrices"> 
      <Grid> 
       <Grid.RowDefinitions> 
        <RowDefinition Height="Auto"/> 
        <RowDefinition Height="1*" /> 
        <RowDefinition Height="Auto"/> 
        <RowDefinition Height="1*" /> 
       </Grid.RowDefinitions> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="1*" /> 
       </Grid.ColumnDefinitions> 
       <TextBlock Text="Prices (in order of priority)" /> 
       <Grid Grid.Row="1"> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="40"/> 
        </Grid.RowDefinitions> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="1*" /> 
         <ColumnDefinition Width="Auto" /> 
        </Grid.ColumnDefinitions> 

        <ListBox HorizontalAlignment="Stretch" Margin="{StaticResource DefaultMargin}" x:Name="lstMenuItemPrices" SelectionMode="Single" 
          ItemsSource="{Binding }" ItemTemplate="{StaticResource MenuItemPriceDataTemplate}" Height="140" > 

         <i:Interaction.Triggers> 
          <i:EventTrigger EventName="SelectionChanged"> 
           <cmd:EventToCommand Command="{Binding DataContext.UpdateSelectedTaxGroupsCommand, ElementName=Editor}" CommandParameter="{Binding SelectedItem, ElementName=lstMenuItemPrices}" /> 
          </i:EventTrigger> 
         </i:Interaction.Triggers> 
        </ListBox> 
        <StackPanel VerticalAlignment="Center" Grid.Column="1" > 
         <Button Content="Move Up" HorizontalAlignment="Center" Margin="2" IsEnabled="{Binding SelectedIndex, Converter={StaticResource MinimumIntegerToBooleanConverter}, ConverterParameter=0, ElementName=lstMenuItemPrices, Mode=OneWay}" /> 
         <Button Content="Move Down" HorizontalAlignment="Center" Margin="2" IsEnabled="{Binding SelectedIndex, Converter={StaticResource MinimumIntegerToBooleanConverter}, ConverterParameter=0, ElementName=lstMenuItemPrices, Mode=OneWay}" /> 
        </StackPanel> 

        <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="2"> 
         <Button HorizontalAlignment="Left" Margin="2" Content="New Price" Command="{Binding DataContext.AddPriceCommand, ElementName=Editor}" /> 
         <Button Content="Remove Price" HorizontalAlignment="Left" Margin="2" Command="{Binding DataContext.RemovePriceCommand, ElementName=Editor}" CommandParameter="{Binding SelectedItem, ElementName=lstMenuItemPrices}" 
           IsEnabled="{Binding SelectedIndex, Converter={StaticResource MinimumIntegerToBooleanConverter}, ConverterParameter=0, ElementName=lstMenuItemPrices, Mode=OneWay}"/> 
        </StackPanel> 
       </Grid> 
       <TextBlock Text="Selected Price" Grid.Row="2" /> 

       <Grid Grid.Row="3"> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="Auto"/> 
         <ColumnDefinition Width="1*"/> 
         <ColumnDefinition Width="1*"/> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="*"/> 
         <RowDefinition Height="*"/> 
        </Grid.RowDefinitions> 

        <CheckBox Content="Amount Includes Tax" d:LayoutOverrides="Width, Height" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" 
              IsChecked="{Binding SelectedItem.DTO.AmountIncludesTax, Mode=TwoWay, ElementName=lstMenuItemPrices}" Grid.ColumnSpan="3"/> 
        <TextBlock HorizontalAlignment="Right" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Text="Amount" Grid.Row="1"/> 
        <TextBlock Text="Cost" d:LayoutOverrides="Width, Height, GridBox" HorizontalAlignment="Right" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Grid.Row="2"/> 
        <TextBlock HorizontalAlignment="Right" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Text="Points" Grid.Row="3"/> 
        <TextBlock HorizontalAlignment="Right" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Text="Interface ID" Grid.Row="4"/> 

        <TextBox VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" Margin="{StaticResource DefaultMargin}" 
            Text="{Binding SelectedItem.DTO.Amount, Mode=TwoWay, ElementName=lstMenuItemPrices, Converter={StaticResource DecimalToMoneyStringConverter}}" /> 
        <CheckBox Content="Open" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Grid.Row="1" Grid.Column="2" 
             IsChecked="{Binding SelectedItem.DTO.IsOpenAmount, Mode=TwoWay, ElementName=lstMenuItemPrices}"/> 

        <TextBox Text="{Binding SelectedItem.DTO.Cost, Converter={StaticResource DecimalToMoneyStringConverter}, Mode=TwoWay, ElementName=lstMenuItemPrices}" TextWrapping="Wrap" 
            Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" d:LayoutOverrides="GridBox" Grid.Column="1" Grid.Row="2"/> 
        <CheckBox Content="Inherit" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Grid.Column="2" Grid.Row="2" 
             IsChecked="{Binding SelectedItem.DTO.CostOverride, Converter={StaticResource CostToBooleanConverter}, Mode=TwoWay, ElementName=lstMenuItemPrices}" /> 

        <TextBox Text="{Binding SelectedItem.DTO.PointsEarned, Converter={StaticResource IntegerToStringConverter}, Mode=TwoWay, ElementName=lstMenuItemPrices}" TextWrapping="Wrap" 
            Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Grid.Column="1" Grid.Row="3" 
            IsEnabled="{Binding SelectedItem.DTO.PointsEarnedInherited, Converter={StaticResource ReverseBooleanConverter}, ElementName=lstMenuItemPrices}"/> 
        <CheckBox Content="Inherit" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Grid.Column="2" Grid.Row="3" 
             IsChecked="{Binding SelectedItem.DTO.InheritPointsEarned, Mode=TwoWay, ElementName=lstMenuItemPrices}" /> 

        <TextBox Margin="{StaticResource DefaultMargin}" Grid.Column="1" Grid.Row="4" 
            Text="{Binding SelectedItem.DTO.InterfaceID, Mode=TwoWay, ElementName=lstMenuItemPrices}" /> 

        <CheckBox Margin="{StaticResource DefaultMargin}" VerticalAlignment="Center" Content="Inherit tax from class" HorizontalAlignment="Left" 
             IsChecked="{Binding SelectedItem.DTO.InheritTaxes, Mode=TwoWay, ElementName=lstMenuItemPrices}" Grid.Row="5" Grid.ColumnSpan="3" /> 

        <ListBox Margin="{StaticResource DefaultMargin}" Grid.Row="6" Grid.ColumnSpan="3" SelectionMode="Multiple" ItemsSource="{Binding DataContext.Repository.TaxGroups, ElementName=Editor}" 
            IsEnabled="{Binding SelectedItem.DTO.InheritTaxes, Converter={StaticResource BooleanToEnabledConverter}, ElementName=lstMenuItemPrices, ConverterParameter=false}"> 
         <ListBox.ItemContainerStyle> 
          <Style TargetType="ListBoxItem" > 
           <Setter Property="Margin" Value="2, 2, 2, 0" /> 
           <Setter Property="Template"> 
            <Setter.Value> 
             <ControlTemplate TargetType="ListBoxItem"> 
              <Border Background="Transparent"> 
               <CheckBox IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" 
                 Content="{Binding DTO.Name}" Padding="5,0,10,0" > 
                <i:Interaction.Triggers> 
                 <i:EventTrigger EventName="Checked"> 
                  <cmd:EventToCommand Command="{Binding SelectedItem.AddTaxGroupCommand, ElementName=lstMenuItemPrices}" CommandParameter="{Binding DTO.ID}" /> 
                 </i:EventTrigger> 
                 <i:EventTrigger EventName="Unchecked"> 
                  <cmd:EventToCommand Command="{Binding SelectedItem.RemoveTaxGroupCommand, ElementName=lstMenuItemPrices}" CommandParameter="{Binding DTO.ID}" /> 
                 </i:EventTrigger> 
                </i:Interaction.Triggers> 
               </CheckBox> 
              </Border> 
             </ControlTemplate> 
            </Setter.Value> 
           </Setter> 
          </Style> 
         </ListBox.ItemContainerStyle> 
        </ListBox> 
       </Grid> 
      </Grid> 
     </DataTemplate> 

ответ

0

ребенок В ScrollViewer нуждается в управлять его собственной высота и ширина. Ваша самая внешняя сетка в вашем ContentTemplate не указует HorizontalAlignment или VerticalAlignment так это недобросовестное к стоимости участка ... вы можете попробовать установить выравнивание влево и сверху следующим образом:

<Grid HorizontalAlignment="Left" VerticalAlignment="Top"> 

Суть в том, внешний внешний контейнер внутри вашего шаблона управления должен устанавливать его высоту и ширину для своего содержимого, а не для родительского контейнера.

+0

опубликовано. Похоже, что scrollviewer переполняет нижнюю часть TabItem, потому что я не вижу стрелку вниз. –

+0

Это не сработало. Изменение размера TabControl по-прежнему просто выталкивает scrollviewer из нижней части. Для меня это похоже на то, что элемент управления TabItem не говорит своим детям, какой размер им нужно. –

+0

странно ... Я не могу воссоздать вашу проблему. Как выглядит родительский элемент XAML TabControl? –

Смежные вопросы