<Window x:Class="ReAct_PME.DetailEmailSend"
        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:ReAct_PME"
        mc:Ignorable="d"
        Title="Detail des messages d'une conversation" Height="450" Width="800" Background="#FFF0F0F0">
    <Window.Resources>
        <!-- Template des messages entrants -->
        <DataTemplate x:Key="IncomingMessageTemplate">
            <StackPanel Margin="10" HorizontalAlignment="Left">
                <TextBlock Text="{Binding SubjectSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <TextBlock Text="{Binding FolderSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <TextBlock Text="{Binding FromSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <TextBlock Text="{Binding ToSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <TextBlock Text="{Binding DateSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <Border Background="SandyBrown" CornerRadius="10" Padding="10" MaxWidth="450">
                    <TextBlock Text="{Binding Body}" TextWrapping="Wrap"/>
                </Border>
            </StackPanel>
        </DataTemplate>

        <!-- Template des messages sortants -->
        <DataTemplate x:Key="OutgoingMessageTemplate">
            <StackPanel Margin="10" HorizontalAlignment="Right">
                <TextBlock Text="{Binding SubjectSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <TextBlock Text="{Binding FolderSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <TextBlock Text="{Binding FromSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <TextBlock Text="{Binding ToSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <TextBlock Text="{Binding DateSTR}" FontSize="10" Foreground="DarkSlateGray"/>
                <Border Background="Blue" CornerRadius="10" Padding="10" MaxWidth="450">
                    <TextBlock Text="{Binding Body}" Foreground="White" TextWrapping="Wrap"/>
                </Border>
            </StackPanel>
        </DataTemplate>

        <!-- Sélecteur -->
        <local:MessageTemplateSelector x:Key="MessageSelector"
                                       IncomingTemplate="{StaticResource IncomingMessageTemplate}"
                                       OutgoingTemplate="{StaticResource OutgoingMessageTemplate}"/>
    </Window.Resources>

    <!-- Conteneur scrollable -->
    <ScrollViewer VerticalScrollBarVisibility="Auto">
        <ItemsControl ItemsSource="{Binding MessagesSorted}"
                      ItemTemplateSelector="{StaticResource MessageSelector}"/>
    </ScrollViewer>
</Window>