I’ve created UserControl:
public partial class MyTemplate : UserControl
{
public MyUser User { get; set; }
}
And then have written the following code in the main window’s xaml
<Window.Resources>
<DataTemplate x:Key="My">
<local:MyTemplate Margin="10"/>
</DataTemplate>
<Window.Resources>
<ListBox x:Name="MyMainList"
ItemTemplate="{StaticResource My}">
ItemsSource="{Binding Path=MyTimelineTweets}"
IsSynchronizedWithCurrentItem="True">
Where MyTimelineTweets has type ObservableCollection and MyTemplate user control shows data from MyFavouriteClass.
The question is:
How can I initialize MyTemplate.User in the xaml or in the code behind? //If the information about User is accessible only at the window level.