Wpf Bind View to ViewModel add to wpf window?

Firstly, ensure that the AllOwners collection you are binding to is an ObservableCollection.

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

I have a view that contains a ItemsControl with some textblocks inside to display the name and other information. In my window I am adding the view to the window as follows and in the code behind of the window I am binding the datacontext of the view to the view model in the MainWindow Loaded event as follows ViewOwnerSideBar. DataContext = viewModel The application compiles but when I run it I don't get data?

I checked my viewmodel and I do have data in my collection that I am returning. Does anyone have any good examples of how to do this. I am going to have a sidebar view and a main view on the right displaying the details of the owner.

This is my View This is my window Zoom: wpf mvvm binding link|improve this question asked Jul 15 '10 at 20:48spafa9213 0% accept rate.

Firstly, ensure that the AllOwners collection you are binding to is an ObservableCollection. Also, check the Output window in Visual Studio when executing, look for First chance exceptions being caught. This will be a clue as to where your binding problem will be.

I like to put a textblock on the View bound to the Items. Count property on the ItemsControl so that you can see if it is binding and not rendering anything or not binding correctly. Give the ItemsControl a name, then put a textblock in.

I am returning an ObservableCollection. I will try that today and see what is happening with it. Thank you for you help!

It is greatly appreciated. – spafa9 Jul 16 '10 at 13:17 Thank you very much for the suggestion to look at the output window. I do have an exception.

It cant find the AllOwner collection so I am not looking into it. Thank you again. – spafa9 Jul 16 '10 at 13:38.

And I guess I'm blind but I don't see where your usercontrol is in the xaml of the second entry.

This is where I am adding the view to the window I have something messed up because I put a name on the ItemsControl and get the count and have 0 so my guess is I have bound the viewModel in the wrong place or the collection is incorrect. I have to passdown credentials to get the data so I am having to bind it in code instead of xaml. – spafa9 Jul 20 '10 at 14:07.

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