MattNiznak
Topic Author
Posts: 6
Joined: 14 Oct 2019, 10:17

Trouble with implementing behaviors

28 Jan 2020, 22:52

[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?

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1777
Joined: 22 Dec 2011, 19:20

Re: Trouble with implementing behaviors

29 Jan 2020, 10:51

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
 
User avatar
jsantos
Site Admin
Posts: 2791
Joined: 20 Jan 2012, 17:18
Contact:

Re: Trouble with implementing behaviors

29 Jan 2020, 12:15

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
 
MattNiznak
Topic Author
Posts: 6
Joined: 14 Oct 2019, 10:17

Re: Trouble with implementing behaviors

30 Jan 2020, 22:11

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?
 
MattNiznak
Topic Author
Posts: 6
Joined: 14 Oct 2019, 10:17

Re: Trouble with implementing behaviors

31 Jan 2020, 02:36

Nevermind. I figured out that adding
#define NS_APP_INTERACTIVITY_PRIVATE
to Interactivityapi.h fixes the dll linkage problem.
 
User avatar
jsantos
Site Admin
Posts: 2791
Joined: 20 Jan 2012, 17:18
Contact:

Re: Trouble with implementing behaviors

04 Feb 2020, 17:05

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.

Who is online

Users browsing this forum: Google [Bot] and 18 guests