I have got a little problem that I am unable to fix. The problem is that when I initialise scrollbar, it does not stay only in screen. To be more specific, its height is actually set to "auto", I think, because it does not let me scroll and it goes to infinite. On the other hand, when I set height to "500" it lets me scroll through it and everything works fine.
Main window:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--
<Frame x:Name="MainFrame" Grid.Row ="1" Grid.Column="1" Content="{Binding CurrPage}" Source="../pages/test_page.xaml" />
-->
<Grid Height="500">
<local:MessageList>
<local:ChatListControl VerticalAlignment="Top">
</local:ChatListControl>
</local:MessageList>
</Grid>
</Grid>
Chat list Control (the place where scrollbar is):
<Grid DataContext="{x:Static local:ChatsDesignModule.Instance}" Background="White">
<ScrollViewer VerticalScrollBarVisibility="Visible">
<ItemsControl ItemsSource="{Binding Items}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:OneMessageTMP />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
Is there a way how can I bind in the first window the current size just by binding it to something already pre-existing or I have to somehow get the current max value and then set it using that one ? Thanks in advance. If you have any question on the code, please let me know, I will explain / provide more code if needed :)
set Height="Auto"
to Height="*"
. Height="Auto"
will give the content of the grid row as much space as it wants. Thus the scroll viewer has nothing to scroll on.