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>