nikobarli
Topic Author
Posts: 178
Joined: 26 Apr 2017, 06:23

Is Attached Event supported ?

12 Sep 2017, 10:33

Hi,

Does NoesisGUI support Attached Event ?

Ref: https://docs.microsoft.com/en-us/dotnet ... s-overview
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Is Attached Event supported ?

14 Sep 2017, 01:17

It could be done if you are using C++ SDK.
You would need the UIElementData class to register your custom RoutedEvent inside the reflection block of your class:
NS_IMPLEMENT_REFLECTION(AquariumFilter)
{
  NsMeta<TypeId>("AquariumFilter");
  auto data = NsMeta<UIElementData>(TypeOf<SelfClass>());
  data->RegisterEvent(NeedsCleaningEvent, "NeedsCleaning", RoutingStrategy_Bubble);
}

const RoutedEvent* AquariumFilter::NeedsCleaningEvent;
When used in xaml:
<aqua:Aquarium Name="theAquarium" Height="600" Width="800" aqua:AquariumFilter.NeedsCleaning="WashMe"/>
Code-behind is responsible to make the event and handler connection as explained here: http://www.noesisengine.com/docs/Gui.Co ... connection
Inside the Connect method you will make use of the static methods defined in AquariumFilter to hook the event handler:
void Connect(Noesis::BaseComponent* source, const NsChar* eventName, const NsChar* handlerName)
{
  if (String::Compare(eventName, "NeedsCleaning") == 0 &&
    String::Compare(handlerName, "WashMe") == 0)
  {
    AquariumFilter::AddNeedsCleaningHandler((DependencyObject*)source, MakeDelegate(this, &AquariumPage::WashMe));
    return;
  }
}
 
nikobarli
Topic Author
Posts: 178
Joined: 26 Apr 2017, 06:23

Re: Is Attached Event supported ?

14 Sep 2017, 02:40

Yes, I think that works. Thanks !
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Is Attached Event supported ?

15 Sep 2017, 12:50

Great, marking it as solved.

Who is online

Users browsing this forum: No registered users and 1 guest