# Tutorial Problem: Accessing Parent from child

**URL:** <https://forum.kirupa.com/t/tutorial-problem-accessing-parent-from-child/325287>\
**Category:** web dev\
**Created:** [October 7, 2011, 2:46am UTC](https://forum.kirupa.com/t/tutorial-problem-accessing-parent-from-child/325287 "2011-10-07T02:46:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RZ1](https://avatars.discourse-cdn.com/v4/letter/r/7cd45c/32.png) [@RZ1](https://forum.kirupa.com/u/RZ1)\
**Post date:** [October 7, 2011, 2:46am UTC](https://forum.kirupa.com/t/tutorial-problem-accessing-parent-from-child/325287/1 "2011-10-07T02:46:17Z")

</div>

[SIZE=2]In Blend I am getting Compile error when using method described in [/SIZE][http://www.kirupa.com/blend\_silverlight/accessing\_parent\_pg1.htm](http://www.kirupa.com/blend_silverlight/accessing_parent_pg1.htm)  
= [SIZE=2]The Type or namespace name “MainPage” could not be found (are you missing a directive or assembly reference?[/SIZE]) =

This is in the code-behind file where I added line[FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]MainPage rootPage = Application.Current.RootVisual [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]as[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] MainPage;

[SIZE=1]Incidently I have trouble using App object in code-behind files as well, of a kind like  
[/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] App app = Application.Current;  
[/SIZE][/FONT][/SIZE][/FONT][SIZE=1]with the same Type or namespace error; I made sure I got all the “using” statements like in the App.xaml.cs

[/SIZE]Actually I want to define a global var(s) on application level to store values I can access from various pages in SL application

Thanks for advice,[/SIZE][/FONT][/SIZE][/FONT]
