<ui:Page
    x:Class="ModernWpf.SampleApp.ControlPages.NumberBoxPage"
    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:sc="clr-namespace:SamplesCommon;assembly=SamplesCommon"
    mc:Ignorable="d">

    <ScrollViewer>
        <ui:SimpleStackPanel Style="{StaticResource ControlPageContentPanelStyle}">
            <sc:ControlExample HeaderText="A NumberBox that evaluates expressions.">
                <ui:NumberBox
                    Header="Enter an expression:"
                    Value="NaN"
                    PlaceholderText="1 + 2^2"
                    AcceptsExpression="True" />
            </sc:ControlExample>

            <sc:ControlExample HeaderText="A NumberBox with a spin button.">
                <ui:NumberBox
                    x:Name="NumberBoxSpinButtonPlacementExample"
                    Header="Enter an integer:"
                    Value="10"
                    SpinButtonPlacementMode="Compact"
                    SmallChange="10"
                    LargeChange="100" />

                <sc:ControlExample.Options>
                    <ui:SimpleStackPanel Style="{StaticResource OptionsPanelStyle}">
                        <ui:RadioButtons
                            Header="SpinButton Placement"
                            SelectedItem="{Binding ElementName=NumberBoxSpinButtonPlacementExample, Path=SpinButtonPlacementMode}">
                            <ui:NumberBoxSpinButtonPlacementMode>Inline</ui:NumberBoxSpinButtonPlacementMode>
                            <ui:NumberBoxSpinButtonPlacementMode>Compact</ui:NumberBoxSpinButtonPlacementMode>
                        </ui:RadioButtons>
                    </ui:SimpleStackPanel>
                </sc:ControlExample.Options>
            </sc:ControlExample>

            <sc:ControlExample HeaderText="A formatted NumberBox that rounds to the nearest 0.25.">
                <ui:NumberBox
                    x:Name="FormattedNumberBox"
                    Value="NaN"
                    Header="Enter a dollar amount:"
                    PlaceholderText="0.00" />
            </sc:ControlExample>

            <sc:ControlExample HeaderText="API in action">
                <ui:NumberBox
                    x:Name="NumberBox1"
                    Width="200"
                    Header="Control header"
                    PlaceholderText="A + B"
                    Minimum="0"
                    Maximum="100"
                    SpinButtonPlacementMode="Compact" />

                <sc:ControlExample.Options>
                    <ui:SimpleStackPanel Style="{StaticResource OptionsPanelStyle}">
                        <ui:NumberBox
                            Header="Minimum"
                            Value="{Binding ElementName=NumberBox1, Path=Minimum}" />
                        <ui:NumberBox
                            Header="Maximum"
                            Value="{Binding ElementName=NumberBox1, Path=Maximum}" />
                        <ui:NumberBox
                            Header="SmallChange"
                            SpinButtonPlacementMode="Inline"
                            Value="{Binding ElementName=NumberBox1, Path=SmallChange}" />
                        <ui:NumberBox
                            Header="LargeChange"
                            SpinButtonPlacementMode="Inline"
                            Value="{Binding ElementName=NumberBox1, Path=LargeChange}" />
                        <TextBox
                            ui:ControlHelper.Header="Text"
                            Text="{Binding ElementName=NumberBox1, Path=Text, Mode=OneWay}"
                            IsEnabled="False" />
                        <TextBox
                            ui:ControlHelper.Header="Header"
                            Text="{Binding ElementName=NumberBox1, Path=Header, UpdateSourceTrigger=PropertyChanged}" />
                        <TextBox
                            ui:ControlHelper.Header="PlaceholderText"
                            Text="{Binding ElementName=NumberBox1, Path=PlaceholderText, UpdateSourceTrigger=PropertyChanged}" />
                        <TextBox
                            ui:ControlHelper.Header="Description"
                            Text="{Binding ElementName=NumberBox1, Path=Description, UpdateSourceTrigger=PropertyChanged}" />
                        <ComboBox
                            ui:ControlHelper.Header="ValidationMode"
                            ItemsSource="{Binding Source={x:Type ui:NumberBoxValidationMode}, Converter={StaticResource EnumValuesConverter}}"
                            SelectedItem="{Binding ElementName=NumberBox1, Path=ValidationMode}" />
                        <ComboBox
                            ui:ControlHelper.Header="SpinButtonPlacementMode"
                            ItemsSource="{Binding Source={x:Type ui:NumberBoxSpinButtonPlacementMode}, Converter={StaticResource EnumValuesConverter}}"
                            SelectedItem="{Binding ElementName=NumberBox1, Path=SpinButtonPlacementMode}" />
                        <CheckBox
                            Content="IsWrapEnabled"
                            IsChecked="{Binding ElementName=NumberBox1, Path=IsWrapEnabled}" />
                        <CheckBox
                            Content="AcceptsExpression"
                            IsChecked="{Binding ElementName=NumberBox1, Path=AcceptsExpression}" />
                        <Slider
                            x:Name="CornerRadiusSlider"
                            ui:ControlHelper.Header="CornerRadius"
                            Maximum="20"
                            TickFrequency="1"
                            IsSnapToTickEnabled="True"
                            AutoToolTipPlacement="TopLeft"
                            Value="{Binding ElementName=NumberBox1, Path=CornerRadius, Converter={StaticResource CornerRadiusToDoubleConverter}}" />
                        <ui:NumberBox
                            Header="PopupHorizonalOffset"
                            SpinButtonPlacementMode="Inline"
                            Value="{DynamicResource NumberBoxPopupHorizonalOffset}"
                            ValueChanged="PopupHorizonalOffset_ValueChanged" />
                        <ui:NumberBox
                            Header="PopupVerticalOffset"
                            SpinButtonPlacementMode="Inline"
                            Value="{DynamicResource NumberBoxPopupVerticalOffset}"
                            ValueChanged="PopupVerticalOffset_ValueChanged" />
                    </ui:SimpleStackPanel>
                </sc:ControlExample.Options>
            </sc:ControlExample>
        </ui:SimpleStackPanel>
    </ScrollViewer>
</ui:Page>
