Binding Int auf Text

DrMueller

Erfahrenes Mitglied
Hallo Leute,

nur ganz kleine Frage:

Ich binde eine Textbox an einen Int-Wert eines Objektes, welches ich davor per LINQ auslese. Also so:

Code:
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            int hashCode = int.Parse(NavigationContext.QueryString["hashcode"]);
  
            var selDebtor = from selDebt in Logic.CurrentApp.GlobalDebtorDataContext.Debtors
                            where selDebt.HashCode == hashCode
                            select selDebt;
            Debtor debt = selDebtor.First();

            PageTitle.Text = Logic.GetPhoneContactByHashCode(hashCode).DisplayName;

            Binding binding = new Binding();
            binding.Source = debt;
            binding.Path = new PropertyPath("DebtValue");
            binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
            txtDebtValue.SetBinding(TextBox.TextProperty, binding);
        }

Nun wird allerdings das Objekt bei der FUnktion nicht geupdatet.

Code:
        private void btnOK_Click(object sender, EventArgs e)
        {
            txtDebtValue.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            Logic.CurrentApp.GlobalDebtorDataContext.SubmitChanges();
            NavigationService.GoBack();
        }

Das Objekt ist eine Entity (sagt man dem so) auf einem Datakontext, dies sieht so aus:

Code:
    [Table]
    public class Debtor
    {
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false,
            AutoSync = AutoSync.OnInsert)]
        public int HashCode { get; set; }

        [Column]
        public int DebtValue { get; set; }
    }

Liegt es daran, dass ich einen Int auf das Textproperty binde, oder kann ich dies nicht auf diese besondene Klasse machen?


Danke im Voraus

Müller Matthias
 
Zurück