-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathConversationView.xaml
75 lines (69 loc) · 3.41 KB
/
ConversationView.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<UserControl x:Class="ChatBubbles.ConversationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ChatBubbles"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="460">
<UserControl.Resources>
<local:StringFormatConverter x:Key="StringFormatConverter"/>
<local:PercentageConverter x:Key="PercentageConverter"/>
<Style TargetType="TextBox" x:Key="TextBlockStyle">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="IsReadOnly" Value="True"/>
</Style>
<Style TargetType="TextBlock" x:Key="TimestampStyle">
<Setter Property="Foreground" Value="Green"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="FontSize" Value="12"/>
</Style>
<DataTemplate x:Key="MeTemplate">
<Grid Margin="30, 10, 5, 0"
local:GridUtils.RowDefinitions=",,">
<Rectangle Fill="White"
Grid.RowSpan="2"/>
<TextBox Text="{Binding Path=Text}"
Style="{StaticResource TextBlockStyle}"/>
<TextBlock Text="{Binding Path=Timestamp, Converter={StaticResource StringFormatConverter}, ConverterParameter='ddd, HH:mm'}"
Style="{StaticResource TimestampStyle}"
Grid.Row="1"/>
<Path Data="m 0,0 l 16,0 l 0,16 l -16,-16"
Fill="White"
Margin="0,-1,5,0"
HorizontalAlignment="Right"
Grid.Row="2"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="YouTemplate">
<Grid Margin="5, 10, 30, 0"
local:GridUtils.RowDefinitions=",,">
<Path Data="m 0,0 l 0,16 l 16,0 l -16,-16"
Fill="White"
Margin="5,0,0,-1"
HorizontalAlignment="Left"/>
<Rectangle Fill="White"
Grid.Row="1" Grid.RowSpan="2"/>
<TextBox Text="{Binding Path=Text}"
Style="{StaticResource TextBlockStyle}"
Grid.Row="1"/>
<TextBlock Text="{Binding Path=Timestamp, Converter={StaticResource StringFormatConverter}, ConverterParameter='ddd, HH:mm'}"
Style="{StaticResource TimestampStyle}"
Grid.Row="2"/>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="Black">
<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemTemplateSelector>
<local:MessageTemplateSelector
MeTemplate="{StaticResource MeTemplate}"
YouTemplate="{StaticResource YouTemplate}"/>
</ItemsControl.ItemTemplateSelector>
</ItemsControl>
</Grid>
</UserControl>