Message.Attach, SayHello and CanSayHello

Feb 4, 2011 at 4:13 PM

Hi,

I'm not sure whether this is intentional behavour, and would like a clarification.

I have ShellView with two buttons in a DataTemplate of an ItemsControl, which is bound by Caliburn.Micro to Items.
(Two buttons just demonstrate to me the different methods, in case they operated differently - but they don't)
Where ShellViewModel is    public class ShellViewModel : Conductor<IMyItem>.Collection.OneActive, IShell
MyItem is a test class. And for my test, I only have one MyItem in Items.

I have "CanShow" and "Show" property and method on both the ShellViewModel and MyItem.
The "Show" method will execute on either ShellViewModel or MyItem, but never both.
The "CanShow" property on MyItem never executes, and only ever executes on ShellViewModel

I was expecting both the "CanShow" and "Show" property and method on both the ShellViewModel and MyItem to execute - bubbling up.

Please can you advise.
Thanks
John

        <ItemsControl x:Name="Items" Grid.Row="2" HorizontalAlignment="Center">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>                   
                    <Border BorderThickness="5" BorderBrush="AliceBlue">
                        <StackPanel>
                            <TextBlock Text="{Binding Text1}"/>
                            <Button cal:Message.Attach="Show1" Margin="8">
                                <Grid Width="100">
                                    <StackPanel>
                                        <TextBlock VerticalAlignment="Top"
                                               HorizontalAlignment="Center"
                                               Margin="2"
                                               Text="TOP of button" />
                                        <Image Source="{Binding Icon}"
                                               Width="48"
                                               Height="48"
                                               HorizontalAlignment="Center"/>
                                        <TextBlock Text="BOTTOM of Button" HorizontalAlignment="Center" />
                                    </StackPanel>
                                </Grid>
                            </Button>
                            <Button Content="Button 2">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="Show2" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                            <TextBlock Text="{Binding Text3}"/>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

Coordinator
Feb 4, 2011 at 4:22 PM

Bubbling only takes the first match that it finds.

Feb 4, 2011 at 4:36 PM

Thanks

But what about CanShow. It only ever executes on the parent, ShellViewModel
Is this intended?
John

 

Coordinator
Feb 4, 2011 at 5:00 PM

Can you send me a sample project that reproduces the problem? Please email it to robertheisenberg at hotmail dot com

I will check it out and see if there is a bug that needs fixing.