WPF Databinding Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nelsonbrodyk
    New Member
    • Mar 2008
    • 81

    WPF Databinding Issue

    Hey All,
    I have been able to set up a databinding to a property with the following code:

    Code:
    <TextBox x:Name="txtTextBox" Text="{Binding Path=NameFirst, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
    and in the code:

    Code:
    profile = context.NewProfile();
    profile.NameFirst = "My Name";
    txtTextBox.DataContext = profile;
    Now when I click a button I do the following:
    Code:
    profile = context.NewProfile();
    profile.NameFirst = "Another name";
    Edit: More specifically, the textbox does not reflect the changes to the model.

    But the binding doesn't update. Is this because the WPF databinding is binding to the actual object? If that's the case, then when I point profile to the new Profile object, the old one is still being held in memory by the databinding?

    Is there a way to make this work so that when I move profile, the databinding updates accordingly? I was hoping that it was bound to the variable not necessarily to the data of the variable.

    Thanks!
    Last edited by Curtis Rutland; Nov 14 '08, 06:13 PM. Reason: added [code] tags
Working...