BaseDataWindow: Add fields for season

This commit is contained in:
2023-11-05 12:20:59 +01:00
parent 6435a649b4
commit 7fe2ea76c3
12 changed files with 244 additions and 57 deletions

View File

@ -4,7 +4,7 @@
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="25">
<TextBox x:Name="TextBox" TextAlignment="Right" FontSize="14" VerticalAlignment="Stretch"
Padding="{Binding ElementName=UnitBlock, Path=ActualWidth, Converter={StaticResource WidthToPaddingConverter}}"
Text="{Binding Path=Text, Mode=TwoWay}" TextChanged="TextBox_TextChanged"/>
Text="{Binding Path=Text}" TextChanged="TextBox_TextChanged"/>
<TextBlock x:Name="UnitBlock" Text="{Binding Path=Unit}" Margin="0,0,4,4" FontSize="10"
HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
</Grid>

View File

@ -1,6 +1,5 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace Elwig.Controls {
public partial class UnitTextBox : UserControl {
@ -10,22 +9,29 @@ namespace Elwig.Controls {
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(UnitTextBox));
public string Text {
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
set => SetValue(TextProperty, value ?? "");
}
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register("Unit", typeof(string), typeof(UnitTextBox));
public string Unit {
get => (string)GetValue(UnitProperty);
set => SetValue(UnitProperty, value);
set => SetValue(UnitProperty, value ?? "");
}
public UnitTextBox() {
Text = "";
Unit = "";
InitializeComponent();
DataContext = this;
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs evt) {
if (TextChanged != null) TextChanged(sender, evt);
Text = TextBox.Text;
TextChanged?.Invoke(sender, evt);
}
public new void Focus() {
TextBox.Focus();
}
}
}