Page 1 of 1

UserControl binding to ContentControl's Content

Posted: 09 May 2021, 10:41
by BartekW
Hey, I wanna bind my UserControl *uc to ContentControl's Content so I have declared my UserControl in class
Ptr<UserControl> uc;
Then I create in method new UserControl
void TestMenuContent::OnTab2Focused(BaseComponent * param)
{
	uc = MakePtr<Tab2Content>();
	NS_UNUSED(param);
}
Here is my NsProp
NsProp("ContentTest", &TestMenuContent::uc);
And here is my ContentControl
<Grid Background="Black" Height="450" VerticalAlignment="Top" Opacity="1">
        <ContentControl Content="{Binding ContentTest}"/>
 </Grid>
And it only works if I Create UserControl in constructor it works..
In method OnTab2Focused nothing happens. Yes that method fires.

Am I missing something?

Re: UserControl binding to ContentControl's Content

Posted: 09 May 2021, 17:14
by KeldorKatarn
I'm not sure what you are trying to do here but I can already tell you that it's now how you do things. You don't use controls behind the scenes. They need to be an actual part of the tree.