Skip to content

MonitoredItem that located on base class of subscription viewmodel does not work #281

@sans-eng

Description

@sans-eng

Expected:
MonitoredItems that located on base class of the subscrition viewmodel can update it's value base on server value or write to it.

Current behavior:
any properties that marked with MonitoredItemAttribute on base class of the viewmodel is not updated with the value from the server also cannot write any value to the server.

Step to reproduce:
Create a ViewModelBase class that derived from SubscriptionBase class then create a property that marked with MonitoredItemAttribute with it's node id including the backing field, the ViewModelBase can be abstract or concrete (it doesn't matter, both not work), also the ViewModelBase can be marked with SubscriptionAttribute or not (also neither work as expected),
then create any viewmodel class that marked with SubscriptionAttribute which derived from ViewModelBase including the properties that marked with MonitoredItemItemAttribute with it's node id and backing field, then bind any view control (e.g. TextBox or NumberBox),
then you can see the control that bind to property which marked with MonitoredItemAttribute located on the base class is not work as expected, but the control that bind to property which marked with MonitoredItemAttribute located on the viewmodel class which derived from the ViewModelBase class is working perfectly.

.Net version: .NET 7
UI framwork: WinUI 3 1.5.240802000

Edit: I think it because in the SubscriptionBase constructor, when collecting properties it only get the DeclaredProperties instead of all properties.

how about change to this:

foreach (var propertyInfo in typeInfo.GetProperties().Where(p => p.GetCustomAttribute<MonitoredItemAttribute>() != null))
{
//The rest of the codes
}

instead of:

foreach (PropertyInfo declaredProperty in typeInfo.DeclaredProperties)
{
//The rest of the codes
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions