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裏面沒有列表上的最後一項,但其中一個更接近頂部(如從底部或第三)。
有沒有辦法阻止它滾動到頂部(我不需要這樣做),或者至少迫使他在滾動前選擇適當的項目?
感謝