BeerMaker
BeerMaker

Reputation: 41

ListBox filled by DataTemplate doesn't scroll WPF

I fill listbox via this code:

<ListBox Height="188" HorizontalAlignment="Left" Margin="277,0,0,0" Name="listBoxAtributeValue" VerticalAlignment="Top" Width="191" MaxHeight="188" MaxWidth="191">
        <ItemsControl ItemsSource="{Binding Path=.}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel.Background>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="Black" Offset="0" />
                                <GradientStop Color="#FFFFA029" Offset="1" />
                            </LinearGradientBrush>
                        </StackPanel.Background>
                            <Label Content="{Binding lblText}" />
                            <TextBox Text="{Binding txtBoxContent}" />
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ListBox>

but I can't scroll it. Here is an image of listBox: Here

How can I fix that? Thak you.

Upvotes: 0

Views: 666

Answers (1)

Botz3000
Botz3000

Reputation: 39630

You don't need the ItemsControl inside your ListBox. A ListBox is already an ItemsControl.

Upvotes: 1

Related Questions