Skip to content

Commit

Permalink
Slightly cleaned up the definition for the textbox with a placeholder…
Browse files Browse the repository at this point in the history
… component.
  • Loading branch information
MeltyPlayer committed May 10, 2024
1 parent b56afdf commit 4d8b1df
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Windows.Controls;

namespace uni.ui.wpf.common.textbox {
public interface ITextBox {
string Text { get; set; }
event TextChangedEventHandler TextChanged;

int CaretIndex { get; set; }
int MaxLength { get; set; }

int MaxLines { get; set; }

CharacterCasing CharacterCasing { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<UserControl x:Class="uni.src.ui.wpf.common.TextBoxWithPlaceholder"
<UserControl x:Class="uni.ui.wpf.common.textbox.TextBoxWithPlaceholder"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:uni.src.ui.wpf.common"
xmlns:local="clr-namespace:uni.ui.wpf.common.textbox"
mc:Ignorable="d"
d:DesignHeight="24"
d:DesignWidth="200">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,48 @@
using System.Windows.Controls;
using System.Windows;

namespace uni.src.ui.wpf.common {
namespace uni.ui.wpf.common.textbox {
/// <summary>
/// Interaction logic for WatermarkTextBox.xaml
/// </summary>
public partial class TextBoxWithPlaceholder : UserControl {
public partial class TextBoxWithPlaceholder : UserControl, ITextBox {
private readonly TextBoxWithPlaceholderViewModel viewModel_;

public TextBoxWithPlaceholder(TextBoxWithPlaceholderViewModel viewModel) {
InitializeComponent();
this.viewModel_ = viewModel;
}

public string Text {
get => this.impl_.Text;
set => this.impl_.Text = value;
}

public event TextChangedEventHandler TextChanged {
add => this.impl_.TextChanged += value;
remove => this.impl_.TextChanged -= value;
}

public int CaretIndex {
get => this.impl_.CaretIndex;
set => this.impl_.CaretIndex = value;
}

public int MaxLength {
get => this.impl_.MaxLines;
set => this.impl_.MaxLines = value;
}

public int MaxLines {
get => this.impl_.MaxLines;
set => this.impl_.MaxLines = value;
}

public CharacterCasing CharacterCasing {
get => this.impl_.CharacterCasing;
set => this.impl_.CharacterCasing = value;
}

public string Placeholder {
get => this.viewModel_.Placeholder;
set => this.viewModel_.Placeholder = value;
Expand All @@ -36,7 +66,7 @@ public string Placeholder {
this.placeholder_ = value;
this.PropertyChanged?.Invoke(
this,
new PropertyChangedEventArgs(nameof(Placeholder)));
new PropertyChangedEventArgs(nameof(this.Placeholder)));
}
}
}
Expand Down

0 comments on commit 4d8b1df

Please sign in to comment.