What does Caliburn command not work when button content is changed?
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" />
开发者_StackOverflow <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
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 is correct. However, I would move the attached property on to the Button as well.
精彩评论