[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
You can use any type as a data source as long as it has a public parameterless constructor and at least one public property. Here's a sample of binding to System.String. In the example below, both TextBlock elements have a name, which makes them accessible in the *.cs/vb file. You set the textBox2 binding in the XAML file and the data context in the code behind:
Open in new window
sample = "ABC DEF GHI JKL MNO PQR";
// assign directly to the Text property
tb1.Text = sample;
// register with the binding system
tb2.DataContext = sample;
// there must also be a binding in the XAML
// or here in code
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.