using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Datenbindung
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public static Score score;

        public MainWindow()
        {
            score = new Score("Tim", 2400);

            InitializeComponent();

            // Bindung für das TextBox-Element tbName (2. Registerkarte)
            Binding bndName = new Binding("PlayerName");
            bndName.Source = score;
            bndName.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            tbName.SetBinding(TextBox.TextProperty, bndName);

            /* Mögliche Bindung für das TextBox-Element tbPoints (2. Registerkarte)
             * hier auskommentiert, da die Bindung bereits via XAML erzeugt wird.
            //Binding bndScore = new Binding("PlayerScore");
            //bndScore.Source = score;
            //bndScore.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            //bndScore.Converter = new IntConverter();
            //tbPoints.SetBinding(TextBox.TextProperty, bndScore);
             */
        }

        private void listBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (tbResult != null)
                tbResult.Text = listBox2.SelectedValue.ToString();
        }
    }
}
