c# - MVVM 将 IsEnabled 绑定(bind)到 ViewModel 中的多个 bool 值

标签 c# visual-studio mvvm

我有下面的按钮,它的 IsEnabled 属性绑定(bind)到 ViewModel 中名为 EnableBtn 的 bool 值。

如果我有另一个名为 EnableMail 的 bool 值,我将如何修改它以便 IsEnabled 绑定(bind)到两者?

    <Button IsEnabled="{Binding EnableBtn, Converter={StaticResource InvertBooleanConverter}}" x:Name="SaveSendButton" Grid.Row="0" Grid.Column="1" Text="{i18n:Translate SaveAndSend}" Style="{StaticResource bottomButtonsBlue}" Command="{Binding EmailPlanCommand}"></Button>

最佳答案

    public bool IsBothEnabled
    {
        get
        {
            if (EnableBtn && EnableMail)
                return true;
            return false;
        }
    }

现在将您的 Button.IsEnabled 属性绑定(bind)到 IsBothEnabled。

关于c# - MVVM 将 IsEnabled 绑定(bind)到 ViewModel 中的多个 bool 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44369981/

相关文章:

C#;列表框作为一个对象(容器)

c++ - 关于Qt的初学者问题

c# - c# WPF 中的 idataerrorinfo

.net - 引用和平台之间的 Visual Studio 冲突

visual-studio - 如何在不使用 Visual Studio 的情况下将代码发送到 Team Foundation Server

c# - UWP DataTemplate 中的列未拉伸(stretch)

javascript - 是否有支持在服务器和客户端上共享 View 的 .Net MVC 解决方案?

c# - 如何使用 ClrMD 正确处理非原始 ClrInstanceField 值?

c# - 序列化和过时

c# - Monotouch 访问带返回类型的私有(private) API