[Back to the SDK Overview]
App.xaml
<!--
COPYRIGHT 2018-2020 - PROPERTY OF TOBII AB
2018-2020 TOBII AB - KARLSROVAGEN 2D, DANDERYD 182 53, SWEDEN - All Rights Reserved.
NOTICE: All information contained herein is, and remains, the property of Tobii AB and its suppliers, if any.
The intellectual and technical concepts contained herein are proprietary to Tobii AB and its suppliers and may be
covered by U.S.and Foreign Patents, patent applications, and are protected by trade secret or copyright law.
Dissemination of this information or reproduction of this material is strictly forbidden unless prior written
permission is obtained from Tobii AB.
-->
<Application x:Class="Tobii.InteractionLib.Wpf.SampleApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Tobii.InteractionLib.Wpf.SampleApp"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
App.xaml.cs
using System;
using System.Windows;
namespace Tobii.InteractionLib.Wpf.SampleApp
{
public partial class App : Application
{
public Tobii.InteractionLib.Wpf.InteractionLibWpfHost IntlibWpf { get; private set; }
protected override void OnStartup(StartupEventArgs e) => IntlibWpf = new Tobii.InteractionLib.Wpf.InteractionLibWpfHost();
protected override void OnExit(ExitEventArgs e)
{
IntlibWpf?.Dispose();
base.OnExit(e);
}
}
}
MainWindow.xaml
<!--
COPYRIGHT 2018-2020 - PROPERTY OF TOBII AB
2018-2020 TOBII AB - KARLSROVAGEN 2D, DANDERYD 182 53, SWEDEN - All Rights Reserved.
NOTICE: All information contained herein is, and remains, the property of Tobii AB and its suppliers, if any.
The intellectual and technical concepts contained herein are proprietary to Tobii AB and its suppliers and may be
covered by U.S.and Foreign Patents, patent applications, and are protected by trade secret or copyright law.
Dissemination of this information or reproduction of this material is strictly forbidden unless prior written
permission is obtained from Tobii AB.
-->
<!-- This is the MainWindow UI where we add three rectangle controls to the window.
The rectangles should trigger change color animation from LightSkyBlue to DarkRed
when Gaze enter action is detected, and change color back from DarkRed to LightSkyBlue
when Gaze exit action is detected. -->
<Window x:Class="Tobii.InteractionLib.Wpf.SampleApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpf="clr-namespace:Tobii.InteractionLib.Wpf;assembly=tobii_interaction_lib_wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<ResourceDictionary>
<Style x:Key="RectangleWithGazeAwareAnimation" TargetType="Rectangle">
<Setter Property="Fill" Value="LightSkyBlue" />
<Setter Property="Margin" Value="40, 50" />
<Setter Property="wpf:Behaviors.IsGazeAware" Value="True"></Setter>
<Style.Triggers>
<Trigger Property="wpf:Behaviors.HasGaze" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)"
From="LightSkyBlue" To="DarkRed" Duration="0:0:.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)"
From="DarkRed" To="LightSkyBlue" Duration="0:0:.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</Window.Resources>
<UniformGrid Columns="3">
<Rectangle x:Name="first" Style="{StaticResource RectangleWithGazeAwareAnimation}" />
<Rectangle x:Name="second" Style="{StaticResource RectangleWithGazeAwareAnimation}" />
<Rectangle x:Name="third" Style="{StaticResource RectangleWithGazeAwareAnimation}" />
</UniformGrid>
</Window>
MainWindow.xaml.cs
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
namespace Tobii.InteractionLib.Wpf.SampleApp
{
public partial class MainWindow : Window
{
public MainWindow()
{
((App)Application.Current).IntlibWpf?.WpfBinding?.AddWindow(this);
InitializeComponent();
}
}
}