Skip to content

Commit

Permalink
Merge pull request #1161 from unoplatform/dev/elri/textbox-playground
Browse files Browse the repository at this point in the history
  • Loading branch information
kazo0 authored Aug 9, 2024
2 parents 1052ac6 + b3023aa commit ba5d664
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 1 deletion.
41 changes: 40 additions & 1 deletion Uno.Gallery/Views/SamplePages/TextBoxSamplePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<local:SamplePageLayout>
<local:SamplePageLayout x:Name="SamplePageLayout">

<local:SamplePageLayout.FluentTemplate>
<DataTemplate>
Expand Down Expand Up @@ -217,6 +217,45 @@

</StackPanel>
</smtx:XamlDisplay>

<smtx:XamlDisplay UniqueKey="TextBoxSamplePage_Material_Playground"
smtx:XamlDisplayExtensions.Header="TextBox Playground"
smtx:XamlDisplayExtensions.IgnorePath="XamlDisplay\StackPanel">

<StackPanel Spacing="10"
Padding="20"
HorizontalAlignment="Center"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
Orientation="Vertical">
<TextBox Style="{StaticResource MaterialFilledTextBoxStyle}"
x:Name="txtFilled"
Width="270" />
<TextBox Style="{StaticResource MaterialOutlinedTextBoxStyle}"
x:Name="txtOutlined"
Width="270" />
<StackPanel HorizontalAlignment="Center"
Spacing="8"
Orientation="Horizontal">
<Button Content="Add Header"
Click="AddHeader" />
<Button Content="Add Placeholder"
Click="AddPlaceholder" />
<Button Content="Add Text"
Click="AddText" />
</StackPanel>

<StackPanel VerticalAlignment="Center"
Spacing="8"
Orientation="Horizontal">
<Button Content="Remove Header"
Click="RemoveHeader" />
<Button Content="Remove Placeholder"
Click="RemovePlaceholder" />
<Button Content="Remove Text"
Click="RemoveText" />
</StackPanel>
</StackPanel>
</smtx:XamlDisplay>
</StackPanel>
</DataTemplate>
</local:SamplePageLayout.MaterialTemplate>
Expand Down
87 changes: 87 additions & 0 deletions Uno.Gallery/Views/SamplePages/TextBoxSamplePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,96 @@ namespace Uno.Gallery.Views.Samples
[SamplePage(SampleCategory.UIComponents, "TextBox", Description = "This control allows users to input a textual value.", DocumentationLink = "https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.textbox")]
public sealed partial class TextBoxSamplePage : Page
{
private TextBox txtFilled;
private TextBox txtOutlined;

public TextBoxSamplePage()
{
this.InitializeComponent();

Loaded += (s, e) =>
{
txtFilled = SamplePageLayout.GetSampleChild<TextBox>(Design.Material, "txtFilled");
txtOutlined = SamplePageLayout.GetSampleChild<TextBox>(Design.Material, "txtOutlined");
};
}

private void AddHeader(object sender, RoutedEventArgs e)
{
if (txtFilled != null)
{
txtFilled.Header = "Header";
}

if (txtOutlined != null)
{
txtOutlined.Header = "Header";
}
}

private void RemoveHeader(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.Header = null;
}

if(txtOutlined != null)
{
txtOutlined.Header = null;
}
}

private void AddPlaceholder(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.PlaceholderText = "Placeholder";
}

if(txtOutlined != null)
{
txtOutlined.PlaceholderText = "Placeholder";
}
}

private void RemovePlaceholder(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.PlaceholderText = null;
}

if(txtOutlined != null)
{
txtOutlined.PlaceholderText = null;
}
}

private void AddText(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.Text = "Text";
}

if(txtOutlined != null)
{
txtOutlined.Text = "Text";
}
}

private void RemoveText(object sender, RoutedEventArgs e)
{
if(txtFilled != null)
{
txtFilled.Text = null;
}

if(txtOutlined != null)
{
txtOutlined.Text = null;
}
}
}
}

0 comments on commit ba5d664

Please sign in to comment.