Reputation: 181
How would I go about binding the text in a TextBox
on one page to a global class from another?
My current code:
App.xaml.cs
public static CustomerClass customer = new CustomerClass();
AddCustomer.xaml
<TextBox x:Name="txtLastName" PlaceholderText="Last name"
Text="{x:Bind Path=local:App.customer.LastName}"/>
{x:Bind Path=local:App.customer.LastName}
isn't throwing any errors however when I type into the TextBox
the value in the class remains null and doesn't update.
Have I bound the values correctly?
If so how do I get the class to update?
Edit:
Yes I had bound it correctly
All I had to do was add the properties Mode=TwoWay, UpdateSourceTrigger=PropertyChanged
Solution:
{x:Bind Path=local:App.customer.LastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}
Upvotes: 1
Views: 176
Reputation: 181
Yes it is bound correctly
All you have to do is use the properties Mode=TwoWay, UpdateSourceTrigger=PropertyChanged
Solution:
{x:Bind Path=local:App.customer.LastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}
Upvotes: 1