PRISM2 命令和 silverlight

发布于 2024-07-15 00:52:00 字数 512 浏览 4 评论 0原文

在 Silverlight 中使用命令功能时,我注意到一个奇怪的行为:

当添加命令:Click.Command 和 CommandParameter 属性时,IsEnabled 属性停止运行:

<Button Content="Delete" 
    x:Name="Btn_Delete" 
    Margin="0,0,8,0" 
    MinWidth="75" 
    commands:Click.Command="{Binding DeleteCommand}" 
    commands:Click.CommandParameter="{Binding SelectedDepartment}" 
    IsEnabled="false" /> 

如果我删除命令:属性 IsEnabled 功能正确。 如果 IsEnabled 也绑定到我的视图模型上的值,则此行为是相同的。

这是一个错误吗? 有人知道有什么解决方法吗?

谢谢, 标记

I have noticed a strange behaviour when using the command functionality in Silverlight:

When the adding the commands:Click.Command and CommandParameter property, the IsEnabled property stops functioning:

<Button Content="Delete" 
    x:Name="Btn_Delete" 
    Margin="0,0,8,0" 
    MinWidth="75" 
    commands:Click.Command="{Binding DeleteCommand}" 
    commands:Click.CommandParameter="{Binding SelectedDepartment}" 
    IsEnabled="false" /> 

If I remove the commands: attributes the IsEnabled functions correctly. This behaviour is the same if IsEnabled is bound to a value on my view model too.

Is this a bug? Anyone know of any work arounds?

Thanks,
Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

剑心龙吟 2024-07-22 00:52:01

我现在已经通过在按钮周围添加内容控件来实现解决方法:

<ContentControl IsEnabled="false">
<Button Content="Delete" 
    x:Name="Btn_Delete" 
    Margin="0,0,8,0" 
    MinWidth="75" 
    commands:Click.Command="{Binding DeleteCommand}" 
    commands:Click.CommandParameter="{Binding SelectedDepartment}" 
     />
</ContentControl>

不过仍然有兴趣找到任何“适当”的解决方案。

I've implemented a workaround for now by adding a content control around the button:

<ContentControl IsEnabled="false">
<Button Content="Delete" 
    x:Name="Btn_Delete" 
    Margin="0,0,8,0" 
    MinWidth="75" 
    commands:Click.Command="{Binding DeleteCommand}" 
    commands:Click.CommandParameter="{Binding SelectedDepartment}" 
     />
</ContentControl>

Still interested to find any 'proper' solutions though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文