|
3 | 3 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
4 | 4 | xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
5 | 5 | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
| 6 | + xmlns:i="http://schemas.microsoft.com/xaml/behaviors" |
6 | 7 | xmlns:resx="clr-namespace:Client.UI.Resources"
|
7 | 8 | xmlns:enums="clr-namespace:Client.UI.Enums"
|
8 | 9 | xmlns:viewmodels="clr-namespace:Client.UI.ViewModels.MainGame"
|
9 | 10 | mc:Ignorable="d"
|
10 | 11 | Title="{x:Static resx:Texts.Chat}"
|
11 |
| - d:DesignHeight="200" d:DesignWidth="300"> |
12 |
| - <Grid d:DataContext="{d:DesignInstance Type=viewmodels:ChatViewModel}"> |
| 12 | + d:DesignHeight="200" d:DesignWidth="300" |
| 13 | + d:DataContext="{d:DesignInstance Type=viewmodels:ChatViewModel}"> |
| 14 | + <Grid> |
13 | 15 | <Grid.ColumnDefinitions>
|
14 | 16 | <ColumnDefinition MaxWidth="250" />
|
15 | 17 | <ColumnDefinition Width="3*"/>
|
|
34 | 36 | <RowDefinition />
|
35 | 37 | <RowDefinition Height="Auto"/>
|
36 | 38 | </Grid.RowDefinitions>
|
37 |
| - <ItemsControl ItemsSource="{Binding Messages}" AlternationCount="2"> |
38 |
| - <ItemsControl.ItemTemplate> |
39 |
| - <DataTemplate> |
40 |
| - <TextBlock Text="{Binding Text, Mode=OneWay}" TextWrapping="Wrap" x:Name="MessageTextBlock"> |
41 |
| - <TextBlock.Style> |
42 |
| - <Style TargetType="TextBlock"> |
43 |
| - <Style.Triggers> |
44 |
| - <DataTrigger Binding="{Binding Type}" Value="{x:Static enums:ChatMessageType.System}"> |
45 |
| - <Setter Property="Foreground" Value="OrangeRed"/> |
46 |
| - </DataTrigger> |
47 |
| - </Style.Triggers> |
48 |
| - </Style> |
49 |
| - </TextBlock.Style> |
50 |
| - </TextBlock> |
51 |
| - <DataTemplate.Triggers> |
52 |
| - <Trigger Property="ItemsControl.AlternationIndex" Value="1"> |
53 |
| - <Setter Property="Background" Value="#F1F1F1" TargetName="MessageTextBlock" /> |
54 |
| - </Trigger> |
55 |
| - </DataTemplate.Triggers> |
56 |
| - </DataTemplate> |
57 |
| - </ItemsControl.ItemTemplate> |
58 |
| - </ItemsControl> |
| 39 | + <ScrollViewer VerticalScrollBarVisibility="Visible" x:Name="ChatScrollViewer"> |
| 40 | + <ItemsControl ItemsSource="{Binding Messages}" AlternationCount="2"> |
| 41 | + <i:Interaction.Triggers> |
| 42 | + <i:EventTrigger SourceObject="{Binding Messages}" EventName="CollectionChanged"> |
| 43 | + <i:CallMethodAction MethodName="ScrollToEnd" TargetObject="{Binding ElementName=ChatScrollViewer}" /> |
| 44 | + </i:EventTrigger> |
| 45 | + </i:Interaction.Triggers> |
| 46 | + <ItemsControl.ItemTemplate> |
| 47 | + <DataTemplate> |
| 48 | + <TextBlock Text="{Binding Text, Mode=OneWay}" TextWrapping="Wrap" x:Name="MessageTextBlock"> |
| 49 | + <TextBlock.Style> |
| 50 | + <Style TargetType="TextBlock"> |
| 51 | + <Style.Triggers> |
| 52 | + <DataTrigger Binding="{Binding Type}" Value="{x:Static enums:ChatMessageType.System}"> |
| 53 | + <Setter Property="Foreground" Value="OrangeRed"/> |
| 54 | + </DataTrigger> |
| 55 | + </Style.Triggers> |
| 56 | + </Style> |
| 57 | + </TextBlock.Style> |
| 58 | + </TextBlock> |
| 59 | + <DataTemplate.Triggers> |
| 60 | + <Trigger Property="ItemsControl.AlternationIndex" Value="1"> |
| 61 | + <Setter Property="Background" Value="#F1F1F1" TargetName="MessageTextBlock" /> |
| 62 | + </Trigger> |
| 63 | + </DataTemplate.Triggers> |
| 64 | + </DataTemplate> |
| 65 | + </ItemsControl.ItemTemplate> |
| 66 | + </ItemsControl> |
| 67 | + </ScrollViewer> |
59 | 68 | <Grid Grid.Row="1">
|
60 | 69 | <Grid.ColumnDefinitions>
|
61 | 70 | <ColumnDefinition />
|
|
0 commit comments