<Window x:Class="MsgBoxEx.MessageBoxEx"
		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"
		mc:Ignorable="d"
        
		Title="{Binding Path=MessageTitle}" 
		MinHeight="100" MaxHeight="{Binding Path=ScreenHeight}"  
		MinWidth="200" MaxWidth="{Binding Path=MaxFormWidth}" 
		Background="{Binding Path=MessageBackground}"
		WindowStartupLocation="CenterScreen"
        ShowInTaskbar="False" 
		WindowStyle="SingleBorderWindow"  
		ResizeMode="NoResize"
		SizeToContent="WidthAndHeight" 
		SizeChanged="NotifiableWindow_SizeChanged" 
		Loaded="Window_Loaded"
		Closing="Window_Closing"
		Height="Auto"
		Width="Auto"
		SourceInitialized="Window_SourceInitialized"
		>

	<Window.Resources>
		<Style x:Key="GroupBoxExpanderToggleButtonStyle" TargetType="{x:Type ToggleButton}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ToggleButton}">
						<Grid SnapsToDevicePixels="False" Background="Transparent">
							<Ellipse HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="15" Height="15" 
									 Fill="{DynamicResource ButtonNormalBackgroundFill}" Stroke="{Binding Path=MessageForeground}"/>
							<Ellipse Visibility="Hidden" HorizontalAlignment="Center" x:Name="shadow" VerticalAlignment="Center" Width="13" Height="13" 
									 Fill="{DynamicResource ExpanderShadowFill}"/>
							<Path SnapsToDevicePixels="false" x:Name="arrow" VerticalAlignment="Center" HorizontalAlignment="Center" 
								  Stroke="{Binding Path=MessageForeground}" StrokeThickness="2" Data="M1,1 L4,4 7,1" />
						</Grid>

						<ControlTemplate.Triggers>
							<Trigger Property="IsChecked" Value="true">
								<Setter Property="Data" TargetName="arrow" Value="M 1,4 L 4,1 L 7,4"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<SolidColorBrush x:Key="GroupBoxBorderBrush" Color="#D0D0BF"/>
		<SolidColorBrush x:Key="GroupBoxHeaderBrush" Color="White"/>
		<BorderGapMaskConverter x:Key="BorderGapMaskConverter"/>

		<Style x:Key="linkCursor" TargetType="{x:Type TextBlock}" >
			<Style.Triggers>
				<Trigger Property="IsMouseOver" Value="True" >
					<Setter Property="Cursor" Value="Hand" />
				</Trigger>
			</Style.Triggers>
		</Style>

	</Window.Resources>

	<Grid >
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>

		<Grid x:Name="gridMsg" Grid.Row="0" Margin="10,10,0,10"  >
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="*" />
			</Grid.ColumnDefinitions>
            <Grid x:Name="imgGrid" Grid.Column="0">
                <Image x:Name="imgMsgBoxIcon" 
					   Source="{Binding Path=MessageIcon}" 
					   Visibility="{Binding Path=ShowIcon}" 
					   Width="32" Height="32"
					   Margin="0,0,10,0" 
					   VerticalAlignment="Top" 
					   MouseLeftButtonUp="ImgMsgBoxIcon_MouseLeftButtonUp" 
					   >
				</Image>
			</Grid>
			<Grid Grid.Column="1" VerticalAlignment="Center" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBox Grid.Row="0" x:Name="textboxMessage"
						 TextWrapping="Wrap" BorderThickness="0" IsReadOnly="True" 
						 ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
						 ScrollViewer.VerticalScrollBarVisibility="Auto" 
						 Padding="0,0,10,0"
						 Background="Transparent" 
						 Foreground="{Binding Path=MessageForeground}" 
						 Text="{Binding Path=Message}" />
			</Grid>
		</Grid>

		<TextBlock Grid.Row="1" x:Name="tbUrl" Margin="0,0,0,10" 
				   Visibility="{Binding Path=ShowUrl}"
				   Foreground="{Binding Path=UrlForeground}"
				   TextWrapping="Wrap"
				   TextDecorations="Underline"
				   HorizontalAlignment="Center"
				   MouseLeftButtonUp="TbUrl_MouseLeftButtonUp"
				   Style="{StaticResource linkCursor}"
				   />

		<CheckBox Grid.Row="2" Margin="0,0,0,10" HorizontalAlignment="Center" 
				  Visibility="{Binding Path=ShowCheckBox}" 
				  Content="{Binding Path=CheckBoxData.CheckBoxText}"
				  IsChecked="{Binding Path=CheckBoxData.CheckBoxIsChecked}"
				  Foreground="{Binding Path=MessageForeground}"></CheckBox>

		<Border x:Name="stackButtons" Grid.Row="3" Padding="10" 
				Background="{Binding Path=ButtonBackground}" >
			<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" >
				<Button x:Name="btnOK" Content=" OK " MinWidth="75" Margin="5,0,5,0" 
						Width="{Binding Path=ButtonWidth}"
                        Height="25"
						Visibility="{Binding Path=ShowOk}" 
						IsDefault="{Binding Path=IsDefaultOK}" 
						Click="BtnOK_Click" />
				<Button x:Name="btnYes" Content=" Yes " MinWidth="75" Margin="5,0,5,0" 
						Width="{Binding Path=ButtonWidth}" 
						Visibility="{Binding Path=ShowYes}" 
						IsDefault="{Binding Path=IsDefaultYes}" 
						Click="BtnYes_Click"/>
				<Button x:Name="btnNo" Content=" No " MinWidth="75" Margin="5,0,5,0" 
						Width="{Binding Path=ButtonWidth}" 
						Visibility="{Binding Path=ShowNo}" 
						IsDefault="{Binding Path=IsDefaultNo}" 
						Click="BtnNo_Click"/>
				<Button x:Name="btnAbort" Content=" Abort " MinWidth="75" Margin="5,0,5,0" 
						Width="{Binding Path=ButtonWidth}" 
						Visibility="{Binding Path=ShowAbort}" 
						IsDefault="{Binding Path=IsDefaultAbort}" 
						Click="BtnAbort_Click"/>
				<Button x:Name="btnRetry" Content=" Retry " MinWidth="75" Margin="5,0,5,0" 
						Width="{Binding Path=ButtonWidth}" 
						Visibility="{Binding Path=ShowRetry}" 
						IsDefault="{Binding Path=IsDefaultRetry}" 
						Click="BtnRetry_Click"/>
				<Button x:Name="btnIgnore" Content=" Ignore " MinWidth="75" Margin="5,0,5,0" 
						Width="{Binding Path=ButtonWidth}" 
						Visibility="{Binding Path=ShowIgnore}" 
						IsDefault="{Binding Path=IsDefaultIgnore}" 
						Click="BtnIgnore_Click"/>
				<Button x:Name="btnCancel" Content=" Cancel " MinWidth="75" Margin="5,0,5,0" 
						Width="{Binding Path=ButtonWidth}" 
						Visibility="{Binding Path=ShowCancel}" 
						IsDefault="{Binding Path=IsDefaultCancel}" 
						Click="BtnCancel_Click"/>
			</StackPanel>
		</Border>

		<Expander Grid.Row="4" Header=" Details" 
				  IsExpanded="{Binding Path=Expanded}"
                  Margin="3,8,0,0"
				  Visibility="{Binding Path=ShowDetailsBtn}"
				  >
			<Expander.Template>
				<ControlTemplate TargetType="{x:Type Expander}">
					<Grid SnapsToDevicePixels="true">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="6" />
							<ColumnDefinition Width="Auto" />
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="6" />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
							<RowDefinition Height="*" />
							<RowDefinition Height="6" />
						</Grid.RowDefinitions>
						<Grid SnapsToDevicePixels="False" Background="Transparent" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2">
							<Grid.ColumnDefinitions>
								<ColumnDefinition />
								<ColumnDefinition />
							</Grid.ColumnDefinitions>
							<ToggleButton Grid.Column="0" MinHeight="0" MinWidth="0" Name="HeaderToggle" 
										  Style="{StaticResource GroupBoxExpanderToggleButtonStyle}"  
										  IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
							<ContentPresenter ContentSource="Header" RecognizesAccessKey="true"  
											  TextElement.Foreground="{Binding ElementName=textboxMessage, Path=Foreground}"  
											  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
											  Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" 
											  />
						</Grid>
						<ContentPresenter x:Name="ExpandSite" Visibility="Collapsed" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" 
									  Margin="{TemplateBinding Padding}" 
									  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsExpanded" Value="true">
							<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{Binding Path=MessageForeground}" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="true">
							<Setter Property="Foreground" Value="{Binding Path=MessageForeground}" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Expander.Template>
			<TextBox x:Name="textboxDetails" Grid.Row="2" Margin="0,10,0,0" Text="{Binding Path=DetailsText}" Height="100" 
					 TextWrapping="Wrap" BorderThickness="0" IsReadOnly="True" 
					 ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
					 ScrollViewer.VerticalScrollBarVisibility="Auto" 
					 Padding="0,0,10,0"
					 Background="Transparent" 
					 Foreground="{Binding Path=MessageForeground}" 
					 />
		</Expander>

	</Grid>
</Window>
