A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

73 lines
4.2 KiB

<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:ControlCatalog.Controls"
x:Class="ControlCatalog.Pages.TextBoxMultilinePage">
<ScrollViewer Padding="24,20,24,28">
<StackPanel Spacing="16">
<controls:SampleSection Header="Multiline"
Description="AcceptsReturn turns the box into an editor: Enter inserts a line break instead of moving focus on. AcceptsTab keeps the Tab key inside the box rather than letting it move focus."
StageMinHeight="200">
<StackPanel Spacing="8">
<TextBox Name="MultilineBox"
Width="380"
HorizontalAlignment="Left"
AcceptsReturn="True"
TextWrapping="Wrap"
MinLines="5"
MaxLines="10"
TextInputOptions.Multiline="True"
Text="Multiline TextBox with TextWrapping.&#xD;&#xD;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam." />
<TextBlock Classes="sample-caption"
TextWrapping="Wrap"
Text="TextInputOptions.Multiline asks an on-screen keyboard for a return key instead of a done key. It is a hint for the keyboard; AcceptsReturn is what actually lets the box hold more than one line." />
</StackPanel>
<controls:SampleSection.Options>
<StackPanel Spacing="8">
<CheckBox Content="AcceptsReturn" IsChecked="{Binding #MultilineBox.AcceptsReturn}" />
<CheckBox Content="AcceptsTab" IsChecked="{Binding #MultilineBox.AcceptsTab}" />
<CheckBox Content="IsReadOnly" IsChecked="{Binding #MultilineBox.IsReadOnly}" />
<TextBlock Text="TextWrapping" Classes="sample-caption" />
<ComboBox SelectedItem="{Binding #MultilineBox.TextWrapping}" HorizontalAlignment="Stretch">
<TextWrapping>NoWrap</TextWrapping>
<TextWrapping>Wrap</TextWrapping>
<TextWrapping>WrapWithOverflow</TextWrapping>
</ComboBox>
</StackPanel>
</controls:SampleSection.Options>
<controls:SampleSection.Code><x:String xml:space="preserve"><![CDATA[<TextBox AcceptsReturn="True"
AcceptsTab="True"
TextWrapping="Wrap"
TextInputOptions.Multiline="True" />]]></x:String></controls:SampleSection.Code>
</controls:SampleSection>
<controls:SampleSection Header="NewLine"
Description="NewLine is the string the box inserts when Enter is pressed. Pick a separator, press Enter a few times and watch the reported line count and separator."
StageMinHeight="170">
<StackPanel Spacing="8">
<TextBox Name="NewLineBox"
Width="320"
HorizontalAlignment="Left"
AcceptsReturn="True"
MinLines="4"
MaxLines="8"
Text="First line" />
<TextBlock Name="NewLineStatus" Classes="sample-caption" TextWrapping="Wrap" />
</StackPanel>
<controls:SampleSection.Options>
<StackPanel Spacing="8">
<TextBlock Text="NewLine" Classes="sample-caption" />
<ComboBox Name="NewLineCombo" SelectedIndex="0" HorizontalAlignment="Stretch">
<ComboBoxItem Content="\n (Unix)" />
<ComboBoxItem Content="\r\n (Windows)" />
<ComboBoxItem Content="\r (classic Mac)" />
</ComboBox>
<Button Content="Append a line in code" Click="OnAppendLine" HorizontalAlignment="Stretch" />
</StackPanel>
</controls:SampleSection.Options>
<controls:SampleSection.Code><x:String xml:space="preserve"><![CDATA[<TextBox AcceptsReturn="True" NewLine="&#10;" />]]></x:String></controls:SampleSection.Code>
</controls:SampleSection>
</StackPanel>
</ScrollViewer>
</UserControl>