tags:

views:

22

answers:

1

I have

<Window x:Class="Repo.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Repo="clr-namespace:Repo" Title="Window1" Height="300" Width="300">
<Grid>
<Button Click="SaVeEverythingInDatabase></Button>
<Repo:UserControlTasks/>

</Grid>
</Window>

public class UserControlTasks:userControl

public partial class UserControlTasks: UserControl
    {
        public UserControlTasks()
        {
            InitializeComponent();
            LoadView();
        }

    private void LoadView()
    {

        this.lbTasks.ItemsSource = new TaskModelView();//collectionOfTasks

    }

How to get collection from lbTasks in UserControlTasks when I click button on MainWindow?

I must add that I this collection is a part of instances of class Student which is datacontext of MainWindow.

+1  A: 

Create TaskModelView in MainWindow class and assign it to Button control and UserControlTasks control. You will need to add a dependecy property for this to UserControlTasks.

Wallstreet Programmer