0

I have quite annoying problem. I have ListBox in a ScrollViewer. ListBox is filled with RadioButton controls. Following code shows it:

<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>

Now when I have enough items on ListBox to show scrollbar I cannot select bottom items. Every time I try to do that - ListBox is scrolled to the top and inside SelectedItem.Value there is not last item on the list, but one of those closer to the top (like 3rd from the bottom or sth).

Is there a way to prevent it from scrolling to the top (I dont need that) or at least make a force him to select proper item before scrolling?

Thanks

Joe
  • 2,551
  • 6
  • 38
  • 60

1 Answers1

0

Simplest solution was the good one in the end. I guess there is no other way than just remove ScrollViewer and let ListBox to scroll its content by itself.

Joe
  • 2,551
  • 6
  • 38
  • 60