<ui:Page
    x:Class="ModernWpf.SampleApp.ControlPages.TextBoxPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="http://schemas.modernwpf.com/2019"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:sc="clr-namespace:SamplesCommon;assembly=SamplesCommon"
    mc:Ignorable="d">

    <ScrollViewer>
        <ui:SimpleStackPanel Style="{StaticResource ControlPageContentPanelStyle}">
            <sc:ControlExample
                x:Name="Example1"
                HeaderText="A simple TextBox.">
                <TextBox AutomationProperties.Name="simple TextBox" />
            </sc:ControlExample>

            <sc:ControlExample
                x:Name="Example2"
                HeaderText="A TextBox with a header and placeholder text.">
                <sc:ControlExample.Example>
                    <TextBox
                        ui:ControlHelper.Header="Enter your name:"
                        ui:ControlHelper.PlaceholderText="Name" />
                </sc:ControlExample.Example>
            </sc:ControlExample>

            <sc:ControlExample
                x:Name="Example3"
                HeaderText="A read-only TextBox with various properties set.">
                <TextBox
                    Text="I am super excited to be here!"
                    IsReadOnly="True"
                    FontFamily="Arial"
                    FontSize="24"
                    FontStyle="Italic"
                    Foreground="CornflowerBlue"
                    AutomationProperties.Name="customized TextBox" />
            </sc:ControlExample>

            <sc:ControlExample
                x:Name="Example4"
                HeaderText="A multi-line TextBox with spell checking and custom selection highlight color.">
                <TextBox
                    TextWrapping="Wrap"
                    AcceptsReturn="True"
                    SpellCheck.IsEnabled="True"
                    SelectionBrush="Green"
                    AutomationProperties.Name="multi-line TextBox" />
            </sc:ControlExample>

            <sc:ControlExample HeaderText="API in action.">
                <TextBox
                    x:Name="textBox"
                    Width="300"
                    ui:ControlHelper.Header="Control header"
                    ui:ControlHelper.PlaceholderText="Placeholder text" />

                <sc:ControlExample.Options>
                    <Expander
                        x:Name="OptionsExpander"
                        Header="Show options"
                        Expanded="OptionsExpander_Expanded"
                        Collapsed="OptionsExpander_Collapsed">
                        <ui:SimpleStackPanel
                            Style="{StaticResource OptionsPanelStyle}"
                            Margin="0,12,0,0">
                            <Button
                                Content="Clear clipboard"
                                Click="ClearClipboard" />
                            <CheckBox
                                Content="AcceptsReturn"
                                IsChecked="{Binding ElementName=textBox, Path=AcceptsReturn}" />
                            <CheckBox
                                Content="IsReadOnly"
                                IsChecked="{Binding ElementName=textBox, Path=IsReadOnly}" />
                            <CheckBox
                                Content="IsReadOnlyCaretVisible"
                                IsChecked="{Binding ElementName=textBox, Path=IsReadOnlyCaretVisible}" />
                            <CheckBox
                                Content="IsUndoEnabled"
                                IsChecked="{Binding ElementName=textBox, Path=IsUndoEnabled}" />
                            <CheckBox
                                Content="IsInactiveSelectionHighlightEnabled"
                                IsChecked="{Binding ElementName=textBox, Path=IsInactiveSelectionHighlightEnabled}" />
                            <TextBox
                                ui:ControlHelper.Header="Header"
                                Text="{Binding ElementName=textBox, Path=(ui:ControlHelper.Header), UpdateSourceTrigger=PropertyChanged}" />
                            <TextBox
                                ui:ControlHelper.Header="PlaceholderText"
                                Text="{Binding ElementName=textBox, Path=(ui:ControlHelper.PlaceholderText), UpdateSourceTrigger=PropertyChanged}" />
                            <ComboBox
                                ui:ControlHelper.Header="TextWrapping"
                                ItemsSource="{Binding Source={x:Type TextWrapping}, Converter={StaticResource EnumValuesConverter}}"
                                SelectedItem="{Binding ElementName=textBox, Path=TextWrapping}" />
                            <ComboBox
                                ui:ControlHelper.Header="HorizontalScrollBarVisibility"
                                ItemsSource="{Binding Source={x:Type ScrollBarVisibility}, Converter={StaticResource EnumValuesConverter}}"
                                SelectedItem="{Binding ElementName=textBox, Path=HorizontalScrollBarVisibility}" />
                            <ComboBox
                                ui:ControlHelper.Header="VerticalScrollBarVisibility"
                                ItemsSource="{Binding Source={x:Type ScrollBarVisibility}, Converter={StaticResource EnumValuesConverter}}"
                                SelectedItem="{Binding ElementName=textBox, Path=VerticalScrollBarVisibility}" />
                            <ComboBox
                                ui:ControlHelper.Header="SelectionOpacity"
                                SelectedItem="{Binding ElementName=textBox, Path=SelectionOpacity}"
                                IsEditable="True">
                                <sys:Double>0</sys:Double>
                                <sys:Double>0.4</sys:Double>
                                <sys:Double>1</sys:Double>
                            </ComboBox>
                        </ui:SimpleStackPanel>
                    </Expander>
                </sc:ControlExample.Options>
            </sc:ControlExample>
        </ui:SimpleStackPanel>
    </ScrollViewer>
</ui:Page>
