当按钮内容更改时,Caliburn 命令不起作用,这是怎么回事?
使用 Caliburn 和 Silverlight,我发现如果我这样做:
<Button PresentationFramework:Message.Attach="ContainerCommand InstructorProfileCommand()"
Height="60"
Content="Instructor" />
那么它就会起作用并调用 InstructorProfileCommand.Execute() 方法。但是,如果我这样做:
<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>
Execute() 命令不会被触发。 附加属性是否处于正确的工作位置?
京东
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测是,在第二种情况下,您应该使用以下语法:
因为如果未明确指定触发器(事件单击),框架会尝试根据消息附加到的元素来推断它。
My guess is that, in the second case, you should use the syntax:
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.