Home Forums Software Development C# WPF project Question Reply To: C# WPF project Question

#2823
Jenny [Tobii]
Participant

Hi Yagoub,

Please, check out the WPF sample UserPresenceWpf in the EyeX SDK for .Net:
There a WpfEyeXHost is created and started in App.xaml.cs. Then a MainWindowModel is created supplying the EyeX host to the constructor. Finally, the window model is supplied as the data context when creating the MainWindow. This way, the EyeX host will be available for usage in the MainWindowModel class.

With a corresponding design you can set up the data stream and the event handling in the constructor of your MainWindowModel. Make sure to dispose the EyeX host and unsubscribe from the event handling at application teardown. Note also that the data stream events will arrive on a background thread, so make sure to switch to run on the main UI thread as needed.