L
L
LiptonOlolo2018-02-03 19:12:40
WPF
LiptonOlolo, 2018-02-03 19:12:40

WPF: How to enable normal scrolling for a ListBox if it is in a StackePanel?

When the elements of the ListBox go beyond the form, there is no scroll, if done through the ScrollViewer, it turns out that the entire column starts to scroll, what to do?

<StackPanel Grid.Column="0"
                    Margin="5">
            <TextBlock Style="{StaticResource TextBlockAsLabel}"
                       Text="Проходящий студент"
                       Margin="2"/>

            <ComboBox ItemsSource="{Binding Groups}"
                      Margin="2"
                      SelectedItem="{Binding GroupFilter}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name, StringFormat={}Группа - {0}}"
                                   Style="{StaticResource TextBlockAsLabel}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>

            <ListBox ItemsSource="{Binding Students}"
                     Margin="2"
                     SelectedItem="{Binding TestFilterStudent}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding SurName, StringFormat={}Фамилия: {0}}" 
                                       Margin="2"/>
                            <TextBlock Text="{Binding Name, StringFormat={}Имя: {0}}"
                                       Margin="2"/>
                            <TextBlock Text="{Binding MiddleName, StringFormat={}Отчество: {0}}" 
                                       Margin="2"/>
                            <TextBlock Text="{Binding Group.Name, StringFormat={}Группа: {0}}"
                                       Margin="2"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </StackPanel>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LiptonOlolo, 2018-02-03
@LiptonOlolo

Solved: grid.row and grid.column.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question