小编Tar*_*run的帖子

使用IDataErrorInfo在验证期间启用禁用保存按钮

如何在使用时进行验证时禁用/启用按钮IDataErrorInfo

我正在使用MVVMGalaSoft light Framework.在我的Model类中,我实现IDataErrorInfo了显示错误消息.

public string this[string columnName]
{
    get
    {
        Result = null;
        if (columnName == "FirstName")
        {
            if (String.IsNullOrEmpty(FirstName))
            {
                Result = "Please enter first name";
            }
        }
        else if (columnName == "LastName")
        {
            if (String.IsNullOrEmpty(LastName))
            {
                Result = "Please enter last name";
            }
        }

        else if (columnName == "Address")
        {
            if (String.IsNullOrEmpty(Address))
            {
                Result = "Please enter Address";
            }
        }

        else if (columnName == "City")
        {
            if (String.IsNullOrEmpty(City))
            {
                Result = …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm light

9
推荐指数
2
解决办法
2万
查看次数

如何根据条件隐藏wpf xaml中上下文菜单的菜单项

在我的xaml中,我使用wpf ContextMenu来显示wpf datagid中的菜单项。我需要根据条件隐藏菜单项。我尝试了以下方法,但它不起作用。

<ContextMenu x:Key="contextMenuTextCell">


            <MenuItem Name="copyDealContextMenu"
                    Header="Copy Deal"
                    Command="{Binding RelativeSource={RelativeSource AncestorType=DataGrid}, Path=DataContext.CopyDeal}"
                    CommandParameter="{Binding}">

                <Style TargetType="{x:Type MenuItem}">
                    <Setter Property="Visibility" Value="Collapsed"></Setter>
                    <Style.Triggers>
                        <DataTrigger Binding="{ Binding ElementName= BlotGrid,Path=DataContext.ProductType }" Value="FXO">
                            <Setter Property="Visibility" Value="Visible"></Setter>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>

            </MenuItem>

        </ContextMenu>
Run Code Online (Sandbox Code Playgroud)

如何隐藏上下文菜单中的菜单项?

谢谢

wpf xaml mvvm visual-studio-2012

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

mvvm ×2

wpf ×2

c# ×1

light ×1

visual-studio-2012 ×1

xaml ×1