<Window x:Class="CefFlashBrowser.Views.BrowserWindow"
        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:CefFlashBrowser.Views"
        xmlns:m="clr-namespace:CefFlashBrowser.Models"
        xmlns:data="clr-namespace:CefFlashBrowser.Data"
        xmlns:flash="clr-namespace:CefFlashBrowser.FlashBrowser;assembly=CefFlashBrowser.FlashBrowser"
        xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:behaviors="clr-namespace:CefFlashBrowser.Views.Behaviors"
        xmlns:converters="clr-namespace:CefFlashBrowser.Views.Converters"
        xmlns:hc="https://handyorg.github.io/handycontrol"
        xmlns:c="clr-namespace:CefFlashBrowser.Views.Custom"
        mc:Ignorable="d"
        
        x:Name="window"
        Width="Auto"
        Height="Auto"
        MinWidth="400"
        MinHeight="300"
        Title="{Binding ElementName=browser, Path=Title, TargetNullValue=FlashBrowser}"
        DataContext="{Binding Source={StaticResource Locator}, Path=BrowserWindowViewModel}">

    <Window.Resources>
        <!--Converters-->
        <converters:MultiplyConverter x:Key="TwoThirdConverter"
                                      Multiplier="0.6666666666666667"/>

        <!--ConetxtMenu-->
        <!--more-->
        <ContextMenu x:Key="more"
                     VerticalOffset="-8"
                     HorizontalOffset="8">
            <MenuItem Header="{DynamicResource browser_showMainWindow}"
                      Command="{Binding ShowMainWindowCommand}"
                      InputGestureText="Ctrl+M"/>

            <MenuItem Header="{DynamicResource browser_newBrowserWindow}"
                      Command="{Binding NewBrowserWindowCommand}"
                      CommandParameter="{Binding Address}"
                      InputGestureText="Ctrl+N"/>

            <Separator/>

            <MenuItem>
                <MenuItem.Template>
                    <ControlTemplate TargetType="MenuItem">
                        <Grid Margin="{TemplateBinding Padding}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="26"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <ContentPresenter Grid.Column="0"
                                              Content="{TemplateBinding Icon}"/>
                            <ContentPresenter Grid.Column="1"
                                              Content="{TemplateBinding Header}"/>
                        </Grid>
                    </ControlTemplate>
                </MenuItem.Template>
                <MenuItem.Header>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0"
                                   VerticalAlignment="Center">
                            <Run Text="{DynamicResource browser_zoom}"/><Run Text="{Binding ZoomLevel, Converter={StaticResource ZoomLevelToScale}, StringFormat={}: {0:p0}}"/>
                        </TextBlock>
                        <hc:ButtonGroup Grid.Column="1"
                                        Margin="0,0,43,0"
                                        Orientation="Horizontal">
                            <Button Width="30"
                                    Height="30"
                                    Padding="0"
                                    ToolTip="{DynamicResource browser_toolTipZoomOut}"
                                    Command="{Binding Source={x:Reference Name=browser}, Path=ZoomOutCommand}">
                                <Button.Content>
                                    <svgc:SvgIcon Width="10"
                                                  Height="10"
                                                  UriSource="/Assets/Svgs/sub.svg">
                                        <svgc:SvgIcon.LayoutTransform>
                                            <!--disappear when there is only a horzontal line???-->
                                            <RotateTransform Angle="0.01"/>
                                        </svgc:SvgIcon.LayoutTransform>
                                    </svgc:SvgIcon>
                                </Button.Content>
                            </Button>
                            <Button Width="30"
                                    Height="30"
                                    Padding="0"
                                    ToolTip="{DynamicResource browser_toolTipZoomIn}"
                                    Command="{Binding Source={x:Reference Name=browser}, Path=ZoomInCommand}">
                                <Button.Content>
                                    <svgc:SvgIcon Width="10"
                                                  Height="10"
                                                  UriSource="/Assets/Svgs/add.svg"/>
                                </Button.Content>
                            </Button>
                        </hc:ButtonGroup>
                    </Grid>
                </MenuItem.Header>
            </MenuItem>

            <Separator/>

            <MenuItem Header="{DynamicResource common_favorites}"
                      ItemsSource="{Binding Source={x:Static data:GlobalData.Favorites}}">
                <MenuItem.Style>
                    <Style TargetType="MenuItem"
                           BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Source={x:Static data:GlobalData.Favorites}, Path=Count}"
                                         Value="0">
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </MenuItem.Style>
                <MenuItem.ItemContainerStyle>
                    <Style TargetType="MenuItem"
                           BasedOn="{StaticResource {x:Type MenuItem}}">
                        <!--<Setter Property="Header"
                                Value="{Binding Name}"/>-->
                        <Setter Property="Command"
                                Value="{Binding Source={x:Reference Name=browser}, Path=LoadUrlCommand}"/>
                        <Setter Property="CommandParameter"
                                Value="{Binding Url}"/>
                    </Style>
                </MenuItem.ItemContainerStyle>
                <MenuItem.ItemTemplate>
                    <DataTemplate DataType="{x:Type m:Website}">
                        <TextBlock MaxWidth="200"
                                   TextTrimming="CharacterEllipsis"
                                   Text="{Binding Name}"/>
                    </DataTemplate>
                </MenuItem.ItemTemplate>
            </MenuItem>

            <MenuItem Header="{DynamicResource browser_addFavorite}"
                      Command="{Binding AddFavoriteCommand}"
                      CommandParameter="{x:Reference Name=browser}"
                      InputGestureText="Ctrl+D"/>

            <Separator/>

            <MenuItem Header="{DynamicResource browser_createShortcut}"
                      Command="{Binding CreateShortcutCommand}"
                      CommandParameter="{x:Reference Name=browser}"
                      InputGestureText="Ctrl+Shift+S"/>

            <MenuItem Header="{DynamicResource browser_openInDefaultBrowser}"
                      Command="{Binding OpenInDefaultBrowserCommand}"
                      CommandParameter="{Binding Address}"
                      InputGestureText="Ctrl+O"/>

            <Separator/>

            <MenuItem Header="{DynamicResource browser_toggleDevTool}"
                      Command="{Binding ToggleDevToolsCommand}"
                      CommandParameter="{Binding Source={x:Reference Name=browser}}"
                      InputGestureText="F12"/>

            <MenuItem Header="{DynamicResource browser_viewSource}"
                      Command="{Binding ViewSourceCommand}"
                      CommandParameter="{Binding Address}"
                      InputGestureText="Ctrl+U"/>
        </ContextMenu>

        <!--blocked swfs-->
        <ContextMenu x:Key="blockedSwfs"
                     VerticalOffset="-8"
                     HorizontalOffset="8">
            <ContextMenu.ItemContainerStyle>
                <Style TargetType="MenuItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="MenuItem">
                                <ContentPresenter Content="{TemplateBinding Header}"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ContextMenu.ItemContainerStyle>
            <ContextMenu.ItemsSource>
                <x:Array Type="{x:Type sys:Object}">
                    <TextBlock Margin="35,10"
                               MaxWidth="250"
                               TextWrapping="Wrap"
                               FontWeight="Bold"
                               Foreground="{DynamicResource PrimaryTextBrush}"
                               Text="{DynamicResource browser_tipsBlockedSwfs}"/>
                    <ItemsControl ItemsSource="{Binding Source={x:Reference Name=browser}, Path=BlockedSwfs}">
                        <ItemsControl.Resources>
                            <Style TargetType="MenuItem"
                                   BasedOn="{StaticResource {x:Type MenuItem}}">
                                <Setter Property="Tag"
                                        Value="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext}"/>
                            </Style>
                        </ItemsControl.Resources>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate DataType="{x:Type sys:String}">
                                <MenuItem Command="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Tag.OpenInSwfPlayerCommand}"
                                          CommandParameter="{Binding}">
                                    <MenuItem.Header>
                                        <TextBlock MaxWidth="250"
                                                   TextTrimming="CharacterEllipsis"
                                                   Text="{Binding Converter={StaticResource UrlGetFileName}}"
                                                   ToolTip="{Binding}"/>
                                    </MenuItem.Header>
                                </MenuItem>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </x:Array>
            </ContextMenu.ItemsSource>
        </ContextMenu>
    </Window.Resources>


    <Window.InputBindings>
        <!--<KeyBinding Key="Esc"
                    Command="{Binding ElementName=browser, Path=StopCommand}"/>-->
        <KeyBinding Key="F5"
                    Command="{Binding ElementName=browser, Path=ReloadCommand}"/>
        <KeyBinding Key="F11"
                    Command="{Binding ToggleFullscreenCommand}"
                    CommandParameter="{Binding ElementName=browser}"/>
        <KeyBinding Key="F12"
                    Command="{Binding ToggleDevToolsCommand}"
                    CommandParameter="{Binding ElementName=browser}"/>
        <KeyBinding Gesture="Ctrl+OemPlus"
                    Command="{Binding ElementName=browser, Path=ZoomInCommand}"/>
        <KeyBinding Gesture="Ctrl+OemMinus"
                    Command="{Binding ElementName=browser, Path=ZoomOutCommand}"/>
        <KeyBinding Gesture="Ctrl+0"
                    Command="{Binding ElementName=browser, Path=ZoomResetCommand}"/>
        <KeyBinding Gesture="Ctrl+D"
                    Command="{Binding AddFavoriteCommand}"
                    CommandParameter="{Binding ElementName=browser}"/>
        <KeyBinding Gesture="Ctrl+F"
                    Command="{Binding OpenFindPopupCommand}"/>
        <KeyBinding Gesture="Ctrl+M"
                    Command="{Binding ShowMainWindowCommand}"/>
        <KeyBinding Gesture="Ctrl+N"
                    Command="{Binding NewBrowserWindowCommand}"
                    CommandParameter="{Binding Address}"/>
        <KeyBinding Gesture="Ctrl+O"
                    Command="{Binding OpenInDefaultBrowserCommand}"
                    CommandParameter="{Binding Address}"/>
        <KeyBinding Gesture="Ctrl+P"
                    Command="{Binding ElementName=browser, Path=PrintCommand}"/>
        <KeyBinding Gesture="Ctrl+U"
                    Command="{Binding ViewSourceCommand}"
                    CommandParameter="{Binding Address}"/>
        <KeyBinding Gesture="Ctrl+Shift+S"
                    Command="{Binding CreateShortcutCommand}"
                    CommandParameter="{Binding ElementName=browser}"/>
        <KeyBinding Gesture="Ctrl+W"
                    Command="{Binding ElementName=browser, Path=CloseBrowserCommand}"
                    CommandParameter="{Binding Source={x:Static data:GlobalData.Settings}, Path=DisableOnBeforeUnloadDialog}"/>
        <KeyBinding Gesture="Alt+Left"
                    Command="{Binding ElementName=browser, Path=BackCommand}"/>
        <KeyBinding Gesture="Alt+Right"
                    Command="{Binding ElementName=browser, Path=ForwardCommand}"/>
    </Window.InputBindings>


    <Grid x:Name="mainGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <DockPanel Grid.Row="0"
                   Margin="10">
            <DockPanel.Style>
                <Style TargetType="DockPanel">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Fullscreen}"
                                     Value="True">
                            <Setter Property="Visibility"
                                    Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </DockPanel.Style>

            <DockPanel.Resources>
                <Style TargetType="Button"
                       BasedOn="{StaticResource {x:Type Button}}">
                    <Setter Property="Width" Value="30"/>
                    <Setter Property="Height" Value="30"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </DockPanel.Resources>

            <StackPanel DockPanel.Dock="Left"
                        Orientation="Horizontal">
                <Button ToolTip="{DynamicResource browser_toolTipBack}"
                        Command="{Binding ElementName=browser, Path=BackCommand}">
                    <Button.Content>
                        <svgc:SvgIcon Width="12"
                                      Height="12"
                                      UriSource="/Assets/Svgs/back.svg"/>
                    </Button.Content>
                </Button>

                <Button ToolTip="{DynamicResource browser_toolTipForward}"
                        Command="{Binding ElementName=browser, Path=ForwardCommand}">
                    <Button.Content>
                        <svgc:SvgIcon Width="12"
                                      Height="12"
                                      UriSource="/Assets/Svgs/forward.svg"/>
                    </Button.Content>
                </Button>

                <Button Margin="10,0,0,0"
                        Command="{Binding ToggleLoadingStateCommand}"
                        CommandParameter="{Binding ElementName=browser}">
                    <Button.Style>
                        <Style TargetType="Button"
                               BasedOn="{StaticResource {x:Type Button}}">
                            <Setter Property="Content">
                                <Setter.Value>
                                    <svgc:SvgIcon Width="12"
                                                  Height="12"
                                                  UriSource="/Assets/Svgs/stop.svg"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="ToolTip"
                                    Value="{DynamicResource browser_toolTipStop}"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ElementName=browser, Path=IsLoading}"
                                             Value="False">
                                    <Setter Property="Content">
                                        <Setter.Value>
                                            <svgc:SvgIcon Width="14"
                                                          Height="14"
                                                          UriSource="/Assets/Svgs/reload.svg"/>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="ToolTip"
                                            Value="{DynamicResource browser_toolTipReload}"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>
            </StackPanel>

            <StackPanel DockPanel.Dock="Right"
                        Orientation="Horizontal">
                <!--blocked swfs button-->
                <Button Click="ShowBlockedSwfsButtonClicked"
                        Margin="0,0,10,0"
                        ToolTip="{DynamicResource browser_toolTipBlockedSwfs}">
                    <Button.Style>
                        <Style TargetType="Button"
                               BasedOn="{StaticResource {x:Type Button}}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ElementName=browser, Path=HasBlockedSwfs}"
                                             Value="False">
                                    <Setter Property="Visibility"
                                            Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                    <svgc:SvgIcon Width="14"
                                  Height="14"
                                  UriSource="/Assets/Svgs/warning.svg"/>
                </Button>

                <!--find button-->
                <ToggleButton x:Name="findButton"
                              Margin="0,0,10,0"
                              Width="30"
                              Height="30"
                              Padding="0"
                              IsChecked="{Binding ShowFindPopup}">
                    <ToggleButton.Style>
                        <Style TargetType="ToggleButton"
                               BasedOn="{StaticResource {x:Type ToggleButton}}">
                            <Style.Triggers>
                                <Trigger Property="IsChecked"
                                         Value="False">
                                    <Setter Property="Visibility"
                                            Value="Collapsed"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ToggleButton.Style>
                    <svgc:SvgIcon Width="13"
                                  Height="13"
                                  UriSource="/Assets/Svgs/search.svg"/>
                </ToggleButton>

                <!--menu button-->
                <Button Click="MenuButtonClicked"
                        ToolTip="{DynamicResource browser_toolTipMore}">
                    <svgc:SvgIcon Width="10"
                                  Height="10"
                                  UriSource="/Assets/Svgs/more.svg"/>
                </Button>

                <!--find popup-->
                <Popup x:Name="findPopup"
                       Opened="FindPopupOpened"
                       Closed="FindPopupClosed"
                       IsOpen="{Binding ShowFindPopup, Mode=TwoWay}"
                       Placement="AbsolutePoint"
                       AllowsTransparency="True">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Opened">
                            <i:InvokeCommandAction Command="{Binding FindNextTextCommand}"
                                                   CommandParameter="{Binding ElementName=browser}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <hc:Card>
                        <StackPanel Margin="5"
                                    Orientation="Horizontal">
                            <StackPanel.Resources>
                                <Style TargetType="Button"
                                       BasedOn="{StaticResource {x:Type Button}}">
                                    <Setter Property="BorderThickness" Value="0"/>
                                </Style>
                            </StackPanel.Resources>

                            <TextBox x:Name="findTextBox"
                                     Width="200"
                                     MaxLength="100"
                                     BorderThickness="0"
                                     Text="{Binding TextToFind, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Behaviors>
                                    <behaviors:TextBoxSelectAllOnFocus/>
                                </i:Interaction.Behaviors>
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <i:InvokeCommandAction Command="{Binding FindNextTextCommand}"
                                                               CommandParameter="{Binding ElementName=browser}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <TextBox.InputBindings>
                                    <KeyBinding Key="Esc"
                                                Command="{Binding CloseFindPopupCommand}"/>
                                    <KeyBinding Key="Enter"
                                                Command="{Binding FindNextTextCommand}"
                                                CommandParameter="{Binding ElementName=browser}"/>
                                    <KeyBinding Key="Up"
                                                Command="{Binding FindPrevTextCommand}"
                                                CommandParameter="{Binding ElementName=browser}"/>
                                    <KeyBinding Key="Down"
                                                Command="{Binding FindNextTextCommand}"
                                                CommandParameter="{Binding ElementName=browser}"/>
                                </TextBox.InputBindings>
                            </TextBox>

                            <Separator Margin="5,0">
                                <Separator.LayoutTransform>
                                    <RotateTransform Angle="90"/>
                                </Separator.LayoutTransform>
                            </Separator>

                            <Button Command="{Binding FindPrevTextCommand}"
                                    CommandParameter="{Binding ElementName=browser}">
                                <svgc:SvgIcon Width="13"
                                              Height="13"
                                              UriSource="/Assets/Svgs/up.svg"/>
                            </Button>

                            <Button Command="{Binding FindNextTextCommand}"
                                    CommandParameter="{Binding ElementName=browser}">
                                <svgc:SvgIcon Width="13"
                                              Height="13"
                                              UriSource="/Assets/Svgs/down.svg"/>
                            </Button>
                        </StackPanel>
                    </hc:Card>
                </Popup>
            </StackPanel>

            <Grid Margin="10,0"
                  Height="30">
                <!--address-->
                <TextBox Padding="35,0,8,0"
                         Text="{Binding ElementName=browser, Path=Address, Mode=OneWay}">
                    <i:Interaction.Behaviors>
                        <behaviors:TextBoxSelectAllOnFocus/>
                    </i:Interaction.Behaviors>
                    <TextBox.InputBindings>
                        <KeyBinding Key="Enter"
                                    Command="{Binding ElementName=browser, Path=LoadUrlCommand}"
                                    CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=TextBox}, Path=Text}"/>
                    </TextBox.InputBindings>
                </TextBox>
                <!--icon-->
                <StackPanel Orientation="Horizontal"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Left"
                            IsHitTestVisible="False">
                    <ContentControl>
                        <ContentControl.Resources>
                            <Image x:Key="BrowserIcon"
                                   Width="16"
                                   Height="16"
                                   Margin="8,0,5,0"
                                   Source="{Binding ElementName=browser, Path=FaviconUrl, TargetNullValue=pack://application:\,\,\,/Assets/Icons/page.png}"/>
                            <svgc:SvgIcon x:Key="DefaultIcon"
                                          Width="15"
                                          Height="15"
                                          Margin="8.5,0,5.5,0"
                                          UriSource="/Assets/Svgs/page.svg"/>
                        </ContentControl.Resources>
                        <ContentControl.Style>
                            <Style TargetType="ContentControl">
                                <Setter Property="Content"
                                        Value="{StaticResource BrowserIcon}"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ElementName=browser, Path=FaviconUrl}"
                                                 Value="">
                                        <Setter Property="Content"
                                                Value="{StaticResource DefaultIcon}"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding ElementName=browser, Path=FaviconUrl}"
                                                 Value="{x:Null}">
                                        <Setter Property="Content"
                                                Value="{StaticResource DefaultIcon}"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ContentControl.Style>
                    </ContentControl>
                    <Separator Width="20">
                        <Separator.LayoutTransform>
                            <RotateTransform Angle="90"/>
                        </Separator.LayoutTransform>
                    </Separator>
                </StackPanel>
            </Grid>
        </DockPanel>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition x:Name="devtoolsColumn" Width="Auto"
                                  MinWidth="{Binding ElementName=devtoolsContainer, Path=MinWidth}"
                                  MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualWidth, Converter={StaticResource TwoThirdConverter}}"/>
            </Grid.ColumnDefinitions>

            <flash:ChromiumFlashBrowser x:Name="browser"
                                        ZoomLevelIncrement="0.25"
                                        ZoomLevel="{Binding ZoomLevel, Mode=TwoWay}"
                                        Address="{Binding Address, Mode=TwoWay, TargetNullValue='about:blank'}"
                                        FullscreenModeChanged="BrowserFullscreenModeChanged"/>

            <GridSplitter Grid.Column="1"
                          Width="5"
                          Background="Transparent"
                          HorizontalAlignment="Stretch"
                          Visibility="{Binding ElementName=devtoolsContainer, Path=Visibility}"/>

            <c:HwndContainer x:Name="devtoolsContainer"
                             Grid.Column="2"
                             ContentHandle="{Binding IntegratedDevToolsHandle}">
                <c:HwndContainer.Style>
                    <Style TargetType="{x:Type c:HwndContainer}">
                        <Setter Property="MinWidth" Value="300"/>
                        <Style.Triggers>
                            <Trigger Property="ContentHandle"
                                     Value="{x:Static sys:IntPtr.Zero}">
                                <Setter Property="MinWidth" Value="0"/>
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </c:HwndContainer.Style>
            </c:HwndContainer>
        </Grid>

        <Popup x:Name="statusPopup"
               IsOpen="{Binding ElementName=window, Path=IsActive, Mode=OneWay}"
               StaysOpen="True"
               Placement="Absolute"
               AllowsTransparency="True"
               MouseEnter="StatusPopupMouseEnter"
               SizeChanged="StatusPopupSizeChanged">
            <Label x:Name="statusPopupContent"
                   Height="22"
                   Padding="5,0"
                   Opacity="0.85"
                   MaxWidth="{Binding ElementName=mainGrid, Path=ActualWidth, Converter={StaticResource TwoThirdConverter}}">
                <Label.Style>
                    <Style TargetType="Label"
                           BasedOn="{StaticResource {x:Type Label}}">
                        <Setter Property="Content">
                            <Setter.Value>
                                <TextBlock>
                                    <Run Text="{DynamicResource browser_loading}"/><Run Text="{Binding ElementName=browser, Path=LoadingProgress, StringFormat={} ({0:p0})}"/>
                                </TextBlock>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=browser, Path=IsLoading}" Value="False">
                                <Setter Property="Content">
                                    <Setter.Value>
                                        <TextBlock Text="{Binding ElementName=browser, Path=StatusText}" TextTrimming="CharacterEllipsis"/>
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding ElementName=browser, Path=IsLoading}" Value="False"/>
                                    <Condition Binding="{Binding ElementName=browser, Path=StatusText}" Value=""/>
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </MultiDataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
            </Label>
        </Popup>
    </Grid>
</Window>
