bloxstrap/Bloxstrap/UI/Menu/Views/Pages/InstallationPage.xaml.cs
pizzaboxer 991005c6a7
Improve channel input selection handling
input value is now trimmed, as well as input being processed on enter
2023-06-28 20:57:23 +01:00

38 lines
1.0 KiB
C#

using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using Bloxstrap.UI.Menu.ViewModels;
namespace Bloxstrap.UI.Menu.Views.Pages
{
/// <summary>
/// Interaction logic for InstallationPage.xaml
/// </summary>
public partial class InstallationPage
{
public InstallationPage()
{
DataContext = new InstallationViewModel();
InitializeComponent();
}
// https://stackoverflow.com/a/13289118/11852173
// yes this doesnt fully conform to xaml but whatever
private void TextBox_KeyEnterUpdate(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
TextBox tBox = (TextBox)sender;
DependencyProperty prop = TextBox.TextProperty;
BindingExpression binding = BindingOperations.GetBindingExpression(tBox, prop);
if (binding is not null)
binding.UpdateSource();
}
}
}
}