Sviluppo TradingBot
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Windows.Controls;
|
||||
using DesktopBot.ViewModels;
|
||||
|
||||
namespace DesktopBot.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Code-behind per SettingsView.
|
||||
/// Gestisce il PasswordBox (non bindabile in WPF) passando il valore al ViewModel.
|
||||
/// </summary>
|
||||
public partial class SettingsView : UserControl
|
||||
{
|
||||
private SettingsViewModel ViewModel => DataContext as SettingsViewModel;
|
||||
|
||||
public SettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Quando il DataContext cambia, pre-popola il PasswordBox
|
||||
DataContextChanged += (s, e) =>
|
||||
{
|
||||
if (ViewModel?.ApiSecret != null)
|
||||
ApiSecretBox.Password = ViewModel.ApiSecret;
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna il ViewModel ogni volta che l'utente modifica il PasswordBox
|
||||
/// </summary>
|
||||
private void ApiSecretBox_PasswordChanged(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
if (ViewModel != null)
|
||||
ViewModel.ApiSecret = ApiSecretBox.Password;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user