<Window x:Class="FlexSheetSample.FindReplaceWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Find and Replace" MinHeight="245" MinWidth="480" Height="245" Width="480" 
        WindowStyle="ToolWindow" WindowStartupLocation="CenterScreen" Topmost="True">

    <Grid Background="LightGray">
        <Grid.RowDefinitions>
            <RowDefinition Height="170" />
            <RowDefinition Height="35" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TabControl Name="_tab" Margin="5" Grid.Row="0" SelectionChanged="_tab_SelectionChanged">
            <TabItem Header="Find" Name="_tabFind"/>
            <TabItem Header="Replace" Name="_tabReplace"/>
        </TabControl>

        <Grid Margin="5,30,10,5">
            <Grid Height="60" VerticalAlignment="Top">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Label Content="Find what:" Grid.Row="0" Grid.Column="0"></Label>
                <ComboBox Name="_comboFind" IsEditable="True" Height="25" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3"></ComboBox>

                <Label Name="_lbReplace" Content="Replace with:" Grid.Row="1" Grid.Column="0"></Label>
                <ComboBox Name="_comboReplace" IsEditable="True" Height="25" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3"></ComboBox>
            </Grid>

            <Grid Height="65" VerticalAlignment="Bottom">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50"></ColumnDefinition>
                    <ColumnDefinition Width="100"></ColumnDefinition>
                    <ColumnDefinition Width="180"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Label Content="Within:" Grid.Row="0" Grid.Column="0"></Label>
                <ComboBox Name="_comboWithin" Width="90" Height="25" Grid.Row="0" Grid.Column="1" SelectionChanged="_comboWithin_SelectionChanged">
                    <ComboBoxItem Content="Sheet" IsSelected="True"></ComboBoxItem>
                    <ComboBoxItem Content="Workbook"></ComboBoxItem>
                </ComboBox>
                <CheckBox Name="_chkMatchCase" Grid.Row="0" Grid.Column="2" Content="Match case" VerticalAlignment="Center" Click="_chkMatchCase_Click"></CheckBox>

                <Label Content="Search:" Grid.Row="1" Grid.Column="0"></Label>
                <ComboBox Name="_comboSearch" Width="90" Height="25" Grid.Row="1" Grid.Column="1" SelectionChanged="_comboSearch_SelectionChanged">
                    <ComboBoxItem Content="By Rows" IsSelected="True"></ComboBoxItem>
                    <ComboBoxItem Content="By Columns"></ComboBoxItem>
                </ComboBox>
                <CheckBox Name="_chkMatchAll" Grid.Row="1" Grid.Column="2" Content="Match entire cell contents" VerticalAlignment="Center" Click="_chkMatchAll_Click"></CheckBox>
            </Grid>
        </Grid>

        <StackPanel Name="_stack" Grid.Row="1" Orientation="Horizontal" Margin="5,0,5,0" HorizontalAlignment="Right">
            <Button Name="_btnReplaceAll" Content="Replace All" Width="75" Height="25" Margin="5" Click="_btnReplaceAll_Click"></Button>
            <Button Name="_btnReplace" Content="Replace" Width="75" Height="25" Margin="5" Click="_btnReplace_Click"></Button>
            <Button Name="_btnFindAll" Content="Find All" Width="75" Height="25" Margin="20,5,5,5" Click="_btnFindAll_Click"></Button>
            <Button Name="_btnFindNext" Content="Find Next" Width="75" Height="25" Margin="5" Click="_btnFindNext_Click"></Button>
            <Button Name="_btnClose" Content="Close" Width="75" Height="25" Margin="20,5,0,5" Click="_btnClose_Click"/>
        </StackPanel>

        <DataGrid Name="_dataGrid" Grid.Row="2" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True">
            <DataGrid.Resources>
                <Style TargetType="Hyperlink">
                    <EventSetter Event="Click" Handler="DG_Hyperlink_Click"/>
                </Style>
            </DataGrid.Resources>
            <DataGrid.Columns>
                <DataGridHyperlinkColumn Width="150" Header="Sheet" Binding="{Binding Path=Sheet}"></DataGridHyperlinkColumn>
                <DataGridHyperlinkColumn Width="150" Header="Cell" Binding="{Binding Path=Cell}"></DataGridHyperlinkColumn>
                <DataGridHyperlinkColumn Width="*" Header="Value" Binding="{Binding Path=Value}"></DataGridHyperlinkColumn>
            </DataGrid.Columns>
        </DataGrid>

    </Grid>
</Window>
