Page 1 of 1

Trouble with implementing behaviors

Posted: 28 Jan 2020, 22:52
by MattNiznak
[NOESIS/E] DragTest.xaml(14): Unknown type 'NoesisApp.Interaction'.

<ContentControl>
            <i:Interaction.Behaviors>
                <local:DropItemBehavior/>
            </i:Interaction.Behaviors>
            <Grid Height="320" HorizontalAlignment="Center" Margin="129,12" Width="245" VerticalAlignment="Center">

                <Rectangle Stroke="Black" AllowDrop="True" Fill="Black" />
                <TextBlock Text="Black" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
            </Grid>
</ContentControl>
I was trying to implement behaviors, without using noesisapp.dll. While my code works in blend, when I try to carry it across to Noesis, I get an error saying that it can't recognize my behaviors. Also, I register my behavior before loading the xaml:
NsRegisterComponent<Test::DropItemBehavior>();
What does Noesis need to know to be able to identify behaviors?

Re: Trouble with implementing behaviors

Posted: 29 Jan 2020, 10:51
by sfernandez
Hi, interactivity classe are part of NoesisApp.dll, so if you don't link against that library you need to copy interactivity code files to your application and register the components in the factory before you can use them from xaml. I explained this in the following post: viewtopic.php?f=3&t=1893#p10663

Re: Trouble with implementing behaviors

Posted: 29 Jan 2020, 12:15
by jsantos
We recommend just including all the needed NoesisApp files from a single cpp file and then registering them. You can use NoesisApp::Launcher::RegisterAppComponents() for that or just make your own version.

This thread may be useful: viewtopic.php?f=3&t=1636

Re: Trouble with implementing behaviors

Posted: 30 Jan 2020, 22:11
by MattNiznak
Thanks for that. I still have issues with adding the files, themselves. I get a ton of inconsistent dll linkage errors. Does this mean I need to remove the 'NS_APP_INTERACTIVITY_API' tag from the classes?

Re: Trouble with implementing behaviors

Posted: 31 Jan 2020, 02:36
by MattNiznak
Nevermind. I figured out that adding
#define NS_APP_INTERACTIVITY_PRIVATE
to Interactivityapi.h fixes the dll linkage problem.

Re: Trouble with implementing behaviors

Posted: 04 Feb 2020, 17:05
by jsantos
Yes, sorry about that. We did minor changes in 3.0 to have this more clear:
#ifndef __APP_INTERACTIVITYAPI_H__
#define __APP_INTERACTIVITYAPI_H__

#include <NsCore/CompilerSettings.h>

#ifndef NS_APP_INTERACTIVITY_API
    #define NS_APP_INTERACTIVITY_API NS_DLL_IMPORT
#endif

#endif
So, in 3.0 just include all the needed files from a single .cpp and define NS_APP_INTERACTIVITY_API to empty.