I use WPF Catel. Faced a problem:
//обошенный класс унаследованный от ModelBase public sealed class TestType<T> : ModelBase { #region Constructor public TestType() { } #endregion #region Properties public ushort Val { get { return GetValue<ushort>(ValProperty); } set { SetValue(ValProperty, value); } } public static readonly PropertyData ValProperty = RegisterProperty("Val", typeof(ushort)); #endregion }
// View Model where I use Model
public class MainWindowViewModel : ViewModelBase { #region Properties [Model] public TestType<bool> Xxx { get { return GetValue<TestType<bool>>(XxxProperty); } set { SetValue(XxxProperty, value); } } public static readonly PropertyData XxxProperty = RegisterProperty("Xxx", typeof(TestType<bool>)); #endregion #region Commands private Command _editCommand; public Command EditCommand { get { return _editCommand ?? (_editCommand = new Command( () => { Xxx = new TestType<bool>(); }, () => true)); } } #endregion }
when assigning an Xml serialization exception to the command body, when Xxx is marked with the [Model] attribute.
And resharper swears: static field in a generalized class
public static readonly PropertyData XxxProperty
If the TestType class is made ordinary, there will be no error. Make PropertyData not static fails swears. Please tell me how to be.
Catel
? This is some kind of internal problem of theModelBase
class, apparently. Where in your code Xml-serialization is unclear. And the message from the resharper has nothing to do with the problem (and most likely it is simply wrong). - VladD