DataContext binding to a rectangle?

The Rectangles do not contain the TextBlocks in both cases a StackPanel does, you should set the DataContext on them instead.

Up vote 0 down vote favorite share g+ share fb share tw.

I have a class Student with 3 attributes (first name, last name, age). In . Xaml ( basically two rectangles - each containing 3 text blocks bind to those 3 attributes).

In .xaml. Cs Student student1 = new Student { FirstName = "James", LastName = "Peter", Age= 12 ,IsAvailable=true }; Student student2 = new Student { FirstName = "Mark", LastName = "Smith", Age = 20 }; after InitializeComponent InitializeComponent(); DataContext = student1; When I run I get James Peter 12 James Peter 12 I want on form load James Peter 12 Mark Smith 20 I tried to use this, but didn't work: rectangle1. DataContext=student1; rectangle2.

DataContext=student2; How do I set two different values for these 2 rectangles? C# wpf xaml data-binding link|improve this question edited Feb 11 at 1:10H.B.43k61645 asked Feb 11 at 1:05Sharpeye500651213 62% accept rate.

The Rectangles do not contain the TextBlocks, in both cases a StackPanel does, you should set the DataContext on them instead.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions