|
<syncfusion:SfTextBoxExt x:Name="policy" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AcceptsReturn="True" AcceptsTab="True" VerticalScrollBarVisibility="Auto" MaxHeight="30"/> |
Hi NM van Strien,
Greetings from Syncfusion.
We have analyzed your requirement and we would like to inform you that our SfTextInputLayout stretch with input views size. So, you can achieve your requirement by setting MaxHeight for SfTextBoxExt as per the below code snippet.
<syncfusion:SfTextBoxExt x:Name="policy" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AcceptsReturn="True" AcceptsTab="True" VerticalScrollBarVisibility="Auto" MaxHeight="30"/>
Please check this solution with your application and let us know if you have any other queries.
Regards,
Sridevi S.
|
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="200"/>
<RowDefinition/>
</Grid.RowDefinitions>
<local:SfTextInputLayoutExt
Grid.Row="1" Hint="Notes" CharCountVisibility="Visible">
<syncfusion:SfTextBoxExt Background="Transparent"
TextWrapping="Wrap" VerticalAlignment="Stretch"/>
</local:SfTextInputLayoutExt>
</Grid> |
|
public class SfTextInputLayoutExt : SfTextInputLayout
{
StackPanel stackPanel;
Grid grid;
TextBlock hint;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
hint = GetTemplateChild("PART_HintTextBlock") as TextBlock;
grid = GetTemplateChild("PART_BottomGrid") as Grid;
stackPanel = VisualTreeHelper.GetChild(this, 0) as StackPanel;
stackPanel.SizeChanged += StackPanel_SizeChanged;
}
private void StackPanel_SizeChanged(object sender, SizeChangedEventArgs e)
{
double top = InputViewPadding.Top < 0 ? ContainerType == ContainerType.Outlined ? 14
: HintVisibility == Visibility.Visible && HintFloatMode != HintFloatMode.None
? ContainerType == ContainerType.Filled ? 20 : 26
: 14 : InputViewPadding.Top;
double bottom = InputViewPadding.Bottom < 0 ? this.ContainerType == ContainerType.Filled ? 8 :
this.ContainerType == ContainerType.Outlined ? 14 : 2 : InputViewPadding.Bottom;
Margin = new Thickness(0, hint.ActualHeight / 2, 0, 0);
InputView.Height = stackPanel.ActualHeight - top - bottom -
grid.ActualHeight - (FocusedStrokeThickness * 2) - hint.ActualHeight / 2;
stackPanel.SizeChanged -= StackPanel_SizeChanged;
}
} |
|
<Grid Margin="10">
<Grid.Resources>
<SolidColorBrush x:Key="DisabledContainerBackground"
Color="#05000000"></SolidColorBrush>
<SolidColorBrush x:Key="DisabledForeground"
Color="#42000000"></SolidColorBrush>
<Style x:Key="textInputLayout" TargetType="local:SfTextInputLayoutExt">
<Setter Property="Template">
..
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition />
<RowDefinition/>
</Grid.RowDefinitions>
<syncfusion:SfTextInputLayout Hint="TextBox">
<TextBox Text="Text"/>
</syncfusion:SfTextInputLayout>
<local:SfTextInputLayoutExt Grid.Row="2" Hint="SfTextBoxExt"
CharCountVisibility="Visible"
Style="{StaticResource textInputLayout}">
<syncfusion:SfTextBoxExt Text="TextBox"
TextWrapping="Wrap"
VerticalContentAlignment="Center" />
</local:SfTextInputLayoutExt>
</Grid>
|
|
public class SfTextInputLayoutExt : SfTextInputLayout
{
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
InputView.VerticalAlignment = VerticalAlignment.Stretch;
InputView.GotFocus += InputView_GotFocus;
if (InputView is TextBox)
(InputView as TextBox).TextChanged += SfTextInputLayoutExt_TextChanged;
}
private void SfTextInputLayoutExt_TextChanged(object sender, TextChangedEventArgs e)
{
InputView.VerticalAlignment = VerticalAlignment.Stretch;
}
private void InputView_GotFocus(object sender, RoutedEventArgs e)
{
InputView.VerticalAlignment = VerticalAlignment.Stretch;
}
}
|
|
SfTextInputLayout -> Focus state |
SfTextInputLayoutExt -> Focus state |
|
|
|
|
public class SfTextInputLayoutExt : SfTextInputLayout
{
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
InputView.VerticalAlignment = VerticalAlignment.Stretch;
InputView.GotFocus += InputView_GotFocus;
InputView.LostFocus += InputView_LostFocus;
if (InputView is TextBox)
(InputView as TextBox).TextChanged += SfTextInputLayoutExt_TextChanged;
}
private void InputView_LostFocus(object sender, RoutedEventArgs e)
{
UpdateInputViewAlignment();
}
private void SfTextInputLayoutExt_TextChanged(object sender, TextChangedEventArgs e)
{
UpdateInputViewAlignment();
}
private void InputView_GotFocus(object sender, RoutedEventArgs e)
{
UpdateInputViewAlignment();
}
private void UpdateInputViewAlignment()
{
InputView.VerticalAlignment = VerticalAlignment.Stretch;
}
} |
Hi NM van Strien,
Sorry for the inconvenience caused.
We have checked the reported problem and resolved that problem in
our new sample. We have prepared a sample with the latest NuGet(18.4.0.44).
Please have a sample form below the link.
https://www.syncfusion.com/downloads/support/forum/162580/ze/SfTextInput_Sample-408826358
Let us know if you need any further assistance.
Regards,
Sridevi S.