- camimamedov
- Posts: 6
- Joined:
EventManager.RegisterClassHandler Unity crash
When i am trying to detect button clicks in one "OnButtonClick" method i get unity crash. I guess this handler is not unregister on disable. What can i use instead of it or how can i fix this problem? My noesis version is 3.2.2
Code: Select all
Noesis.EventManager.RegisterClassHandler(typeof(Button), Button.ClickEvent,
new RoutedEventHandler(OnButtonClick));
Re: EventManager.RegisterClassHandler Unity crash
I think this is related to #2359. Is this happening on domain reload?
- camimamedov
- Posts: 6
- Joined:
Re: EventManager.RegisterClassHandler Unity crash
Yes . But your reference post hasn't got any solution for Button clicks.I think this is related to #2359. Is this happening on domain reload?
-
sfernandez
Site Admin
- Posts: 3093
- Joined:
Re: EventManager.RegisterClassHandler Unity crash
Hi,
Do you really need to use EventManager.RegisterClassHandler, which is mostly intended to create custom controls?
Or will be enough to just hook to the Click event of your button in code behind:
Or even better, use a MVVM approach along with Commands to drive your app/game logic:
Please let me know if you need further assistance with any of this approaches.
Do you really need to use EventManager.RegisterClassHandler, which is mostly intended to create custom controls?
Or will be enough to just hook to the Click event of your button in code behind:
Code: Select all
<Grid x:Name="root">
...
<Button x:Name="btn" Content="LOGIN"/>
</Grid>
Code: Select all
Button btn = (Button)root.FindName("btn");
btn.Click += OnButtonClick;
Code: Select all
public class ViewModel
{
public DelegateCommand LoginCommand { get; }
...
}
Code: Select all
<Button Content="LOGIN" Command="{Binding LoginCommand}"/>
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests