Skip to content

Instantly share code, notes, and snippets.

@julesx
Created August 11, 2017 18:13
Show Gist options
  • Save julesx/8a673feb038ad61e44411c7df3dff241 to your computer and use it in GitHub Desktop.
Save julesx/8a673feb038ad61e44411c7df3dff241 to your computer and use it in GitHub Desktop.
MouseEnterTest
<Window x:Class="WpfApplication16.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:local="clr-namespace:WpfApplication16"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<StackPanel MouseEnter="UIElement_OnMouseEnter">
<ListBox>
</ListBox>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction Command="{Binding CmdMouseEnter}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</StackPanel>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Core.Utils.Classes;
namespace WpfApplication16
{
public partial class MainWindow : Window
{
private ICommand _mouseEnter;
public ICommand CmdMouseEnter
{
get
{
if (_mouseEnter == null)
_mouseEnter = new RelayCommand(TestMouseEnter);
return _mouseEnter;
}
}
private void TestMouseEnter(object o)
{
Console.WriteLine("data context mouse enter");
}
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
private void UIElement_OnMouseEnter(object sender, MouseEventArgs e)
{
Console.WriteLine("code behind mouse enter");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment