Caliburn-Micro / Caliburn.Micro

A small, yet powerful framework, designed for building applications across all XAML platforms. Its strong support for MV* patterns will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
http://caliburnmicro.com/
MIT License
2.8k stars 778 forks source link

Message.Attach #790

Open JOHNCARDOEN opened 2 years ago

JOHNCARDOEN commented 2 years ago

My mousemove event does not fire when i start the application in debug mode.

If i then change anything between the qoutation marks eg delete the C of CheckCanApprove and rewrite the C or delete a space and insert the space again and hit the "Apply Code Changes" (red flame) then mouse event will begin firing every time.

Can anyone explain this behaviour or what to do so the mouseevent fires 'normally'?

cal:Message.Attach="[Event MouseMove] = [Action CheckCanApprove]"

Screenshot_MessageAttach

KasperSK commented 2 years ago

I believe that MouseEnter should fire when the mouse passes over the bound of the control, MouseMove should fire when the mouse moves while over the control. As for the event firing it should happen when the events occur.

Can you make a repo that shows this error so that I could test it out?

JOHNCARDOEN commented 2 years ago

I've managed to alter my code ( striped it from external depenencies) to be able to reproduce the 'error' https://github.com/JOHNCARDOEN/Bestelbons.Caliburn Hopefully everything is there you need, because it's my first 'contact' with github. Otherwise we van do a WeTransfer.

vb2ae commented 2 years ago

Thanks for the sample. I would try and create a Pull Request to pull the stuff from master branch in to main

I would make the following changes to get the MouseEnter to work

Need to add xmlns:b

  <UserControl x:Class="WPF_Bestelbons.Views.BestelbonsView"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:WPF_Bestelbons.Converters"
             xmlns:local="clr-namespace:WPF_Bestelbons"
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
             mc:Ignorable="d" 
             Width="350"
             d:DesignHeight="450" d:DesignWidth="800">

and change the button to this

        <Button x:Name="Approve" Grid.Column="1"  Content="Approve"  Width="80" FontSize="12"  Background="#2D2D30" Style="{StaticResource BlueButton}">
            <b:Interaction.Triggers>
                <b:EventTrigger EventName="MouseEnter">
                    <cal:ActionMessage MethodName="CheckCanApprove" />
                </b:EventTrigger>
            </b:Interaction.Triggers>
        </Button>
KasperSK commented 2 years ago

Perhaps you could give this a try aswell:

<Button Grid.Column="1" Content="Approve" Width="80" FontSize="12" Background="#2D2D30" Style="{StaticResource BlueButton}" cal:Message.Attach="[Event Click] = [Action Approve];[Event MouseEnter] = [Action CheckCanApprove]" />

JOHNCARDOEN commented 2 years ago

Hi KasperSk,

Yep the proposed solution did the trick !! If i get the gist : better not to intermingle the 'built in' default button click mapping and the cal:Message.Attach, but when more is needed than the click, do it all with cal:Message.Attach ?

Thanks for the help !

KasperSK commented 2 years ago

I would expect the default convention to work with an action message, so I would classify this as a bug.

I just had a suspicion that somehow the action message did not get hooked up.

Thanks for testing the temporary solution I will do a bug hunt on this :) also thank you for reporting the issue!