views:

118

answers:

2

Using Caliburn and Silverlight, I found that if I do:

            <Button PresentationFramework:Message.Attach="ContainerCommand InstructorProfileCommand()"
                    Height="60"
                    Content="Instructor" />

Then it works and the InstructorProfileCommand.Execute() method is called. However, if I do:

            <Button Height="60" >
                <Grid PresentationFramework:Message.Attach="ContainerCommand InstructorProfileCommand()">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Image Source="/App.Module;Component/Icons/navigate.jpg"
                           Height="50"
                           Width="50" />
                    <TextBlock Text="Instructor Profile"
                               Grid.Column="1"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               Margin="10,0,0,0" />
                </Grid>
            </Button>

The Execute() command is not fired. Is the attached property in the correct place for it to work?

JD

+1  A: 

My guess is that, in the second case, you should use the syntax:

PresentationFramework:Message.Attach="Event Click = ContainerCommand InstructorProfileCommand"

because if the trigger (Event Click) is not explicitly specified, the framework tries to infer it based on element the message is attached to.

Marco Amendola
Hola Marco. Unfortunately the above code does not load and gives an XAML parser error.
JD
There's no Click event on Grid. You would have to use a LeftMouseButtonUp
EisenbergEffect
+1  A: 

Marco is correct. However, I would move the attached property on to the Button as well.

EisenbergEffect