use data context of main window c# code example
Example: wpf setting data context
//Inside your XAML
<Window.DataContext>
<local:FilterElements/>
</Window.DataContext>
//FilterElements being a class you created
//Inside your XAML
<Window.DataContext>
<local:FilterElements/>
</Window.DataContext>
//FilterElements being a class you created