Command binding doens't work C++
Hey, I made method and NsProp'ed this, then I use command in .xaml and I was surprised becouse it didn't work.
Could you help?
And this is what I have in Button
Have u idea why?
Could you help?
Code: Select all
Test::Test()
{
_backClicked.SetExecuteFunc(MakeDelegate(this, &Test::OnBack));
Initialized() += MakeDelegate(this, &Test::OnInitialized);
InitializeComponent();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Test::InitializeComponent()
{
GUI::LoadComponent(this, "Test.xaml");
}
void OurMenu::Test::OnInitialized(Noesis::BaseComponent *, const Noesis::EventArgs &)
{
rootContent = FindName<ContentControl>("RootContent");
}
const NoesisApp::DelegateCommand * OurMenu::Test::GetBackDelegate() const
{
return &_backClicked;
}
void OurMenu::Test::OnBack(BaseComponent * param)
{
NS_UNUSED(param);
MessageBox(0, 0, "Back", 0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
NS_BEGIN_COLD_REGION
NS_IMPLEMENT_REFLECTION(OurMenu::Test, "OurMenu.Test")
{
NsProp("OnBack", &Test::GetBackDelegate);
NS_UNUSED(helper);
}
Code: Select all
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyDown">
<i:InvokeCommandAction Command="{Binding OnBack}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Command binding doens't work C++
It seems you are missing the DataContext for the binding to work:
Code: Select all
Test::Test()
{
_backClicked.SetExecuteFunc(MakeDelegate(this, &Test::OnBack));
Initialized() += MakeDelegate(this, &Test::OnInitialized);
InitializeComponent();
SetDataContext(this);
}
Re: Command binding doens't work C++
Okey I found a problem, I can't use second class to GUI::LoadComponent becouse it doesnt work :|
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Command binding doens't work C++
I don't understand, could you please elaborate what is not working.Okey I found a problem, I can't use second class to GUI::LoadComponent becouse it doesnt work :|
Who is online
Users browsing this forum: Bing [Bot] and 7 guests