Yes, you are right but this is not what I want. I don't want to access from the code behind of the window to a control of the itself. I want to access to the control (listbox) placed in the window from a code behind of the page.
Perhaps I haven't explained well. I'll try again. First when my application starts, it is displayed a window and into this window, in a frame I load a page. Here I post a code snipet:
WinMain.xaml :
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GParts"
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;
assembly=PresentationFramework.Aero"
xmlns:UC="clr-namespace:GParts.UserControls"
x:Class="GParts.WinMain"
Title="GParts"
WindowState="Maximized"
Closing="Window_Closing"
Icon="/Resources/partsIco.gif"
x:Name="WMain"
>
<Grid x:Name="LayoutRoot" Margin="0">
<Grid.Resources>
<XmlDataProvider x:Key="MenuList"
XPath="/Pantallas" Source="/AppData/MnuPantallas.xml" />
<...>
</Grid.Resources>
<...>
<ListBox Name="LayoutListBox"
Margin="0"
DataContext="{Binding Source={StaticResource
MenuList}, XPath=/Pantallas/Category[1]/Screen}"
ItemsSource="{Binding}"
SelectionChanged="HandleSelectionChanged"
Style="{DynamicResource MenuListBox}"
IsSynchronizedWithCurrentItem="True"
SelectedIndex="0"/>
<...>
<ScrollViewer VerticalAlignment="Stretch"
Margin="0"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto">
<Grid DockPanel.Dock="Left" Margin="0" x:Name="frameHost">
<Grid.DataContext>
<Binding Source="{StaticResource MenuList}"
XPath="/Pantallas/Category[1]/Screen"/>
</Grid.DataContext>
<!-- Here, when window loaded in the following frame
for first time I load
PageConsultas.xaml described in the xml file-->
<Frame x:Name="_frameHost" Margin="0" Source="{Binding
XPath=@Path}" Width="Auto"/>
</Grid>
</ScrollViewer>
<...>
</Grid>
</Window>
MnuPantallas.xml contains:
<?xml version="1.0" encoding="utf-8" ?>
<Pantallas xmlns="">
<Category Title="Pantallas">
<Screen Path="\Pages\PageConsultas.xaml" Title="Consultas"
Description="Consultas" />
<Screen Path="\Pages\PageRutas.xaml" Title="Fuentes"
Description="Fuentes" />
</Category>
</Pantallas>
When application starts it displays the main window WinMain.xaml and into its frame, it is shown the page PageConsultas.xaml. WinMain.xaml is always loaded, and into it, in a frame, always is loaded a page, PageConsultas.xaml or PageRutas.xaml depends on the user menu selection. Then in a certain point of the time, from the code behind of one of these pages I want to accces to listbox 'LayoutListBox' placed in the window loaded WinMain.xaml in order to enabled/disabled the listbox. To do that I need to obtain the reference of the WinMain.xaml loaded, search the listbox by its name (LayoutListBox), and then accesss property isEnabled and set it to true or false depends on the case.
Thanks.