You do not want to set the DataContext in the UserControl. Instead, you want to set it in the UserControl area.
Usually you do this in the UserControl constructor. Usually I add a line like this:
this.RootElement.DataContext = myData;
Where RootElement is the first sub-element (Content) of your UserControl (usually a panel like Grid or StackPanel).
In your case, it will be:
this.lsvwOutput.DataContext = FindResource("myDataSource") ;
And make sure it is after calling InitializeComponent ().
This is just a review question. You set the datacontext on the root panel of the usercontrol. This is really an unobvious part of WPF.
UPDATE: As Marcus points out below, in the case of a list, you want to set an array of data, not just a data point. Keep this in mind when setting up a DataContext in your constructor.
cunningdave
source share