Mouse move over an item and an event be generated WPF

Asked

Viewed 38 times

0

I’m having difficulty implementing an effect where when I hover over the item on the screen the speed should be 0. And without the mouse above should be back to 30. Use WPF using MVVM structure, so events cannot be in the Class.xaml.Cs class I need an idea on the subject. Thank you!

<common:BrnN Grid.Row="1"
                                 ItemsSource="{Binding Items}"
                                 Speed="30"
                                 Background="Black">
                <common:BrnN.ItemTemplate>
                    <DataTemplate>
                        <Button Background="Transparent"
                                BorderThickness="0"
                                Margin="20, 0"
                                Padding="0"
                                Command="{Binding RelativeSource={RelativeSource AncestorType=common:BrN}, Path=DataContext.TagCommand}"
                                CommandParameter="{Binding}">

                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Descricao}"
                                           Foreground="Gold"
                                           FontSize="18"
                                           FontWeight="Semibold" />
                                <TextBlock Text=": "
                                           Foreground="Gold"
                                           FontSize="18"
                                           FontWeight="Semibold" />
                                <TextBlock Text="{Binding Valor, StringFormat=F2}"
                                           Foreground="Gold"
                                           FontSize="18"
                                           FontWeight="Semibold" />

                            </StackPanel>
                        </Button>
                    </DataTemplate>
                </common:BrnN.ItemTemplate>
  • 1

    Search for "wpf Event to command".

1 answer

0

You can use events in the code associated with the element in question. I used a button with the name bt_teste to exemplify what I am saying and the following events.

    private void Bt_teste_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
    {
        bt_teste.Content = "fora";
    }

    private void Bt_teste_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
    {
        bt_teste.Content = "sobre";
    }
  • I made this option too, though. It’s not working perfectly. The behavior doesn’t work the way I’d like it to. ** I put in gridRow the enter mouse and Leave mouse and they’re kind of happening together. Besides freezing all the items in a single point they do not rotate again on the screen ** I put on the buttons the enter mouse and the Leave mouse and the two events are happening together. Besides freezing all items at a single point it does not rotate again

Browser other questions tagged

You are not signed in. Login or sign up in order to post.