0
Vote

Fix Scrollbar issues in WGM_Client-Silverlight

description

The scrollbar is set to scroll to bottom when a new message arrives. However instead of figuring out where the bottom is, I just say to sroll to Double.MaxValue, which is a huge number, and may have some random effects. I suggest either using a listbox control instead, and saying scroll to item, where the item is the last message added. This could take some research as you will have to make an item template and bind it to some list type that contains the messages. Goodluck.
Here is an example of the data template.
 
<DataTemplate x:Key="mainTemplate">           
                <Grid Name="MessageItem">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition  />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBox BorderThickness="0" TextWrapping="Wrap">
                        <TextBox.Text>
                            <MultiBinding StringFormat="{}{0} {1} says">
                                <Binding Path="MessageDate" />
                                <Binding Path="Sender"/>                               
                            </MultiBinding>
                        </TextBox.Text>
                    <TextBox.Width>
                        <Binding NotifyOnSourceUpdated="True"  ElementName="_messageList" Path="ActualWidth"/>
                    </TextBox.Width>
                </TextBox>
                <Expander Grid.Row="1" IsExpanded="True" ExpandDirection="Right">                 
                    <TextBox  Grid.Row="1" Text="{Binding Path=MessageText}" Grid.ColumnSpan="1" TextWrapping="Wrap" BorderThickness="1"  Padding="0">
                    <TextBox.Width>
                            <Binding NotifyOnSourceUpdated="True"  ElementName="_messageList" Path="ActualWidth"/>
                        </TextBox.Width>
                    </TextBox>
                </Expander>
            </Grid>          
        </DataTemplate>

comments