<Window x:Class="InABox.Wpf.MessageWindow"
        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:InABox.Wpf"
        mc:Ignorable="d"
        Width="350"
        MinWidth="350"
        SizeToContent="Height"
        x:Name="Window"
        WindowStartupLocation="CenterScreen"
        DataContext="{Binding ElementName=Window}">
    <Window.Resources>
        <DataTemplate x:Key="ButtonTemplate" DataType="local:MessageWindowButton">
            <Button Content="{Binding Content}"
                    MinWidth="75" Padding="5" Margin="5"
                    Click="Button_Click"
                    Tag="{Binding}">

            </Button>
        </DataTemplate>
    </Window.Resources>
    <Grid x:Name="Grid">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" MinHeight="100"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition MaxHeight="150">
                <RowDefinition.Style>
                    <Style TargetType="RowDefinition">
                        <Setter Property="Height" Value="0"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ShowDetails}" Value="True">
                                <Setter Property="Height" Value="*"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </RowDefinition.Style>
            </RowDefinition>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" BorderBrush="LightGray" BorderThickness="1"
                Margin="2" Padding="5" Background="White">
            <DockPanel>
                <Image x:Name="ImageControl" Margin="5" Source="{Binding Image}"
                       DockPanel.Dock="Left" MaxWidth="50" MaxHeight="50">
                    <Image.Style>
                        <Style TargetType="Image">
                            <Setter Property="Visibility" Value="Visible"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Image}" Value="{x:Null}">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
                <TextBlock x:Name="MessageBox" Text="{Binding Message}"
                           TextWrapping="Wrap"
                           Margin="5" VerticalAlignment="Center"
                           DockPanel.Dock="Right"/>
            </DockPanel>
        </Border>
        <Border Grid.Row="1"
                Background="WhiteSmoke" BorderBrush="Gray" BorderThickness="1" Margin="2,0,2,2">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <ItemsControl ItemsSource="{Binding LeftButtons}"
                              Grid.Column="0"
                              ItemTemplate="{StaticResource ButtonTemplate}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
                <ItemsControl ItemsSource="{Binding RightButtons}"
                              Grid.Column="2"
                              ItemTemplate="{StaticResource ButtonTemplate}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
            </Grid>
        </Border>
        <Border Grid.Row="2" BorderBrush="LightGray" BorderThickness="1"
                Margin="2" Padding="2" Background="White">
            <ScrollViewer VerticalScrollBarVisibility="Auto">
                <Border BorderBrush="LightGray" BorderThickness="1"
                        Background="WhiteSmoke">
                    <TextBlock x:Name="DetailsBox" Text="{Binding Details}"
                               TextWrapping="Wrap"
                               Padding="5" VerticalAlignment="Center"/>
                </Border>
            </ScrollViewer>
        </Border>
    </Grid>
</Window>
