如何在使用时进行验证时禁用/启用按钮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) 在我的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)
如何隐藏上下文菜单中的菜单项?
谢谢