我有一个具有属性的类,基于在组合框属性中选择一项,将显示或隐藏其他属性。我正在使用 [RefreshProperties(RefreshProperties.All)] 作为组合框属性。绑定到属性网格的类:
[TypeConverter(typeof(PropertySubsetConverter<FileSystemOperation>))]
public class FileSystemOperation : IPropertySubsetObject
{
[Description("File system operations like Copy, Move, Delete & Check file.")]
[Category("Mandatory")]
[RefreshProperties(RefreshProperties.All)]
public Op Operation { get; set; }
public enum Op
{
/// <summary>
/// Copy file
/// </summary>
CopyFile,
/// <summary>
/// Move file
/// </summary>
MoveFile,
/// <summary>
/// Delete file
/// </summary>
DeleteFile,
/// <summary>
/// Delete directory
/// </summary>
DeleteDirectory,
/// <summary>
/// Check if file exists
/// </summary>
ExistFile
}
}
如果用户选择“DeleteDirectory”,则应显示以下属性并隐藏其他属性
[AppliesTo(Op.DeleteDirectory)]
public bool Recursive { get; set; }
我的 Xaml:
<xctk:PropertyGrid x:Name="pk" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontWeight="ExtraBold" IsEnabled="{Binding PropertyGridIsEnabled}" SelectedObject="{Binding SelectedElement, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Background="#FF4A5D80" Foreground="White"/>
这适用于 Winform 属性网格,但不适用于 Xceed wpf 属性网格。如果我缺少任何要设置的属性,需要帮助。