This is a bit of a noob question but I've just realised that if i create a UserControl and choose to name some of its child elements a la -
<UserControl x:Class="UserControls.uControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Grid x:Name="maingrid">
</Grid>
then i can reference the named elements in the code-behind of the consuming XAML. So for the example above i could write
uControl.mainGrid = new Grid();
I'm curious as to why this is the case and more importantly, how i can safely encapsulate these controls.
As usual, ANY help would be really appreciated.