I have a uCtrl
of type UserControl
in a parentPg
of type Page
(instead of a Window
). And I want to access that parentPg
in uCtrl
class so that I can bind some uCtrl
's property to parentPg
's Control
.
Like as we get in case of Window
.
public partial class uCtrl : UserControl
{
Window parentWin;
public uCtrl()
{
parentWin = Window.GetWindow(this);
}
public bool IsPrptReady
{
get
{
//accesing parent Window's control
if (((pWin)(parentWin)).txt.Text != "")
{
return true;
}
else
{
return false;
}
}
}
}
In above code snippet, I am getting parent Window
(i.e. of type pWin
) in uCtrl
of type UserControl
and then sets its Property
(i.e IsPrptReady
) based on parents Window's Control
i.e. txt
of type 'TextBox'.
I want to do the same thing, but in case of Page
not Window
.
I have seen a lot of questions like this but nothing solves my problem.
Any help will be appreciated.
The XAML code is as below.
<Page x:Class="Stego.Pages.EnDeCoding"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Test"
xmlns:userControls="clr-namespace:Test.UserControls"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800"
>
<Grid>
<userControls:uCtrl x:Name="uCtrlName"/>
</Grid>
</Page>