将 Catel Framework 与 Xceed.Wpf.Toolkit.PropertyGrid 一起使用时出现错误。错误在于,如果我从 ViewModelBase 继承,PropertyGrid 是不可见的自定义属性如果我从 ModelBase 继承,则一切正常
这段代码工作得很好
public class PersonViewModel : ModelBase
{
[DisplayName(@"Название")]
[Description(@"Название стратегии")]
[Category(@"Основные")]
[PropertyOrder(0)]
public string Person
{
get { return GetValue<string>(PersonProperty); }
set { SetValue(PersonProperty, value); }
}
public static readonly PropertyData PersonProperty = RegisterProperty("Person", typeof(string));
}
但是这段代码不起作用
public class PersonViewModel : ViewModelBase
{
[DisplayName(@"Название")]
[Description(@"Название стратегии")]
[Category(@"Основные")]
[PropertyOrder(0)]
public string Person
{
get { return GetValue<string>(PersonProperty); }
set { SetValue(PersonProperty, value); }
}
public static readonly PropertyData PersonProperty = RegisterProperty("Person", typeof(string));
}
XAML
<xcad:LayoutAnchorable ContentId="alarms"
Title="Alarms"
>
<xctk:PropertyGrid BorderThickness="0"
SelectedObject="{Binding Path=SelectedObject}"
ShowSearchBox="False"
ShowSortOptions="False"
Width="Auto"
AutoGenerateProperties="False"
NameColumnWidth="150">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition Name="Person" />
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
</xcad:LayoutAnchorable>