相关疑难解决方法(0)

ICommand - canexecute无法禁用带有图像内容的Button

我的wpf-mvvm应用程序中有一个按钮控件.

我使用ICommand属性(在viewmodel中定义)将按钮单击事件绑定到viewmodel.

我有 - >我的ICommand实现的执行和canexecute参数(RelayCommand).

即使CanExecute为false ...按钮未被禁用... WHEN按钮CONTENT为IMAGE

但是,当按钮内容是text..enable/disable工作正常.

<Button DockPanel.Dock="Top" 
                        Command="{Binding Path=MoveUpCommand}">
                    <Button.Content>
                        <Image Source="/Resources/MoveUpArrow.png"></Image>
                    </Button.Content>
                    <Style>
                        <Style.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" Value=".5" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </Button>
Run Code Online (Sandbox Code Playgroud)

wpf mvvm icommand canexecute

2
推荐指数
1
解决办法
5980
查看次数

标签 统计

canexecute ×1

icommand ×1

mvvm ×1

wpf ×1