2012-09-20 44 views
0

我有一個很煩人的問題。我在ScrollViewer中有ListBox。 ListBox中充滿了RadioButton控件。下面的代碼顯示它:滾動查看器中的RadioButtons WPF列表框 - 選擇前滾動更改

<Grid> 
<Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
</Grid.RowDefinitions> 
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto" CanContentScroll="False"> 
     <ListBox Name="lbActiveProjects" Background="Transparent" 
         Style="{StaticResource RadioButtonList}" SelectedValuePath="Value.IsMainProject" 
         ItemTemplate="{StaticResource ResourceKey=radioButtonActiveProjectsListItem}" 
         ItemsSource="{Binding Path=Model.Worker.ProjectManager.Projects}" 
         SelectedValue="true" FontSize="{Binding Source={x:Static props:Settings.Default}, 
                             Path=SmallerFontSize}" 
         Grid.Row="0" 
         ><!--ScrollViewer.VerticalScrollBarVisibility="Auto"--> 
       <i:Interaction.Triggers> 
         <i:EventTrigger EventName="PreviewMouseUp"> 
           <cmd:EventToCommand Command="{Binding SelectionChangedCommand}" 
                     CommandParameter="{Binding ElementName=lbActiveProjects, Path=SelectedItem.Value}"/> 
         </i:EventTrigger> 
       </i:Interaction.Triggers> 
     </ListBox> 
</ScrollViewer> 
. 
. 
. 
</Grid> 

現在當我有足夠的項目ListBox來顯示滾動條我不能選擇底部項目。每當我嘗試這樣做 - ListBox滾動到頂部和SelectedItem.Value裏面沒有列表上的最後一項,但其中一個更接近頂部(如從底部或第三)。

有沒有辦法阻止它滾動到頂部(我不需要這樣做),或者至少迫使他在滾動前選擇適當的項目?

感謝

回答

0

最簡單的解決方案是一個很好的結尾。我想除了刪除ScrollViewer並讓ListBox自己滾動它的內容之外別無他法。