Caliburn.Micro icon indicating copy to clipboard operation
Caliburn.Micro copied to clipboard

Message.Attach

Open JOHNCARDOEN opened this issue 4 years ago • 6 comments

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

JOHNCARDOEN avatar Jan 03 '22 06:01 JOHNCARDOEN

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?

KasperSK avatar Jan 04 '22 09:01 KasperSK

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.

JOHNCARDOEN avatar Jan 08 '22 15:01 JOHNCARDOEN

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>

vb2ae avatar Jan 08 '22 20:01 vb2ae

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]" />

KasperSK avatar Jan 09 '22 00:01 KasperSK

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 !

JOHNCARDOEN avatar Jan 09 '22 12:01 JOHNCARDOEN

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!

KasperSK avatar Jan 09 '22 13:01 KasperSK