<Window x:Class="Stylet.MessageBoxView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:s="clr-namespace:Stylet.Xaml"
        mc:Ignorable="d"
        ResizeMode="NoResize"
        SizeToContent="WidthAndHeight"
        FlowDirection="{Binding FlowDirection}"
        WindowStartupLocation="CenterScreen"
        ShowInTaskbar="False"
        MinWidth="160" MaxWidth="485"
        x:Name="rootObject">
    <Grid Margin="0,0,0,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="6"/> <!-- Padding -->
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>

        <Image Grid.Row="0" Grid.Column="1" Margin="19,0,0,0" VerticalAlignment="Center"
               Source="{Binding ImageIcon, Converter={x:Static s:IconToBitmapSourceConverter.Instance}}"
               Visibility="{Binding ImageIcon, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
        </Image>

        <TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding Text}" Margin="8,30,15,30" TextWrapping="Wrap" TextAlignment="{Binding TextAlignment}"/>

        <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
            <ItemsControl Grid.Row="1" ItemsSource="{Binding ButtonList}"
                          HorizontalAlignment="Right" VerticalAlignment="Center" Margin="43,0,0,0">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Button Content="{Binding Label}" Width="85" Height="25" Margin="0,0,10,0"
                                Command="{s:Action ButtonClicked}" CommandParameter="{Binding Value}">
                            <Button.IsDefault>
                                <MultiBinding Converter="{x:Static s:EqualityConverter.Instance}">
                                    <Binding/>
                                    <Binding Path="DataContext.DefaultButton" ElementName="rootObject"/>
                                </MultiBinding>
                            </Button.IsDefault>
                            <Button.IsCancel>
                                <MultiBinding Converter="{x:Static s:EqualityConverter.Instance}">
                                    <Binding/>
                                    <Binding Path="DataContext.CancelButton" ElementName="rootObject"/>
                                </MultiBinding>
                            </Button.IsCancel>
                        </Button>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Grid>
    </Grid>
</Window>
